052aa55d34
There are no longer two separate projects living inside the horizon repository. There is a single project now with a single setup.py, single README, etc. The openstack-dashboard/dashboard django project is now named "openstack_dashboard" and lives as an example project in the topmost horizon directory. The "horizon/horizon" directory has been bumped up a level and now is directly on the path when the root horizon directory is on your python path. Javascript media which the horizon module directly relies upon now ships in the horizon/static dir rather than openstack-dashboard/dashboard/static. All the corresponding setup, installation, build, and env scripts have been updated accordingly. Implements blueprint unified-packaging. Change-Id: Ieed8e3c777432cd046c3e0298869a9428756ab62
87 lines
3.2 KiB
Python
87 lines
3.2 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2012 United States Government as represented by the
|
|
# Administrator of the National Aeronautics and Space Administration.
|
|
# All Rights Reserved.
|
|
#
|
|
# Copyright 2012 Nebula, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from horizon import api
|
|
from horizon import test
|
|
|
|
|
|
class GlanceApiTests(test.APITestCase):
|
|
def test_get_glanceclient(self):
|
|
""" Verify the client connection method does what we expect. """
|
|
# Replace the original client which is stubbed out in setUp()
|
|
api.glance.glanceclient = self._original_glanceclient
|
|
|
|
client = api.glance.glanceclient(self.request)
|
|
self.assertEqual(client.auth_tok, self.tokens.first().id)
|
|
|
|
def test_image_get_meta(self):
|
|
""" Verify "get" returns our custom Image class. """
|
|
image = self.images.get(id='1')
|
|
|
|
glanceclient = self.stub_glanceclient()
|
|
glanceclient.get_image_meta(image.id).AndReturn(image)
|
|
self.mox.ReplayAll()
|
|
|
|
ret_val = api.image_get_meta(self.request, image.id)
|
|
self.assertIsInstance(ret_val, api.glance.Image)
|
|
self.assertEqual(ret_val._apidict, image)
|
|
|
|
def test_image_list_detailed(self):
|
|
""" Verify "list" returns our custom Image class. """
|
|
images = self.images.list()
|
|
|
|
glanceclient = self.stub_glanceclient()
|
|
glanceclient.get_images_detailed().AndReturn(images)
|
|
self.mox.ReplayAll()
|
|
|
|
ret_val = api.image_list_detailed(self.request)
|
|
for image in ret_val:
|
|
self.assertIsInstance(image, api.glance.Image)
|
|
self.assertIn(image._apidict, images)
|
|
|
|
|
|
class ImageWrapperTests(test.TestCase):
|
|
""" Tests for wrapper classes since they have extra logic attached. """
|
|
WITHOUT_PROPERTIES = {'size': 100}
|
|
WITH_PROPERTIES = {'properties': {'image_state': 'running'},
|
|
'size': 100}
|
|
|
|
def test_get_properties(self):
|
|
image = api.Image(self.WITH_PROPERTIES)
|
|
image_props = image.properties
|
|
self.assertIsInstance(image_props, api.ImageProperties)
|
|
self.assertEqual(image_props.image_state, 'running')
|
|
|
|
def test_get_other(self):
|
|
image = api.Image(self.WITH_PROPERTIES)
|
|
self.assertEqual(image.size, 100)
|
|
|
|
def test_get_properties_missing(self):
|
|
image = api.Image(self.WITHOUT_PROPERTIES)
|
|
with self.assertRaises(AttributeError):
|
|
image.properties
|
|
|
|
def test_get_other_missing(self):
|
|
image = api.Image(self.WITHOUT_PROPERTIES)
|
|
with self.assertRaises(AttributeError):
|
|
self.assertNotIn('missing', image._attrs,
|
|
msg="Test assumption broken. Find new missing attribute")
|
|
image.missing
|