summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-09-21 18:27:23 +0000
committerTarmac <>2011-09-21 18:27:23 +0000
commit14068bc8f748ee3bee3c5b86ac19cd21b0ff8b67 (patch)
treec0d87fd5a575ef80227ccd35e75e73f9c74827ba /nova/tests
parent7e3bebbe8e911851a7398b8d5ad81afb421dfd62 (diff)
parent10589faa5fbde09689641d5e64ddd41a341eaade (diff)
Adds an 'alternate' link to image views per 3.10 and 3.11 of http://docs.openstack.org/cactus/openstack-compute/developer/openstack-compute-api-1.1/content/LinksReferences.html
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/test_images.py102
-rw-r--r--nova/tests/test_utils.py9
2 files changed, 111 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py
index e5fd4764a..886efb6ac 100644
--- a/nova/tests/api/openstack/test_images.py
+++ b/nova/tests/api/openstack/test_images.py
@@ -33,7 +33,9 @@ from nova import context
import nova.api.openstack
from nova.api.openstack import images
from nova.api.openstack import xmlutil
+from nova.api.openstack.views import images as images_view
from nova import test
+from nova import utils
from nova.tests.api.openstack import fakes
@@ -119,6 +121,7 @@ class ImagesTest(test.TestCase):
href = "http://localhost/v1.1/fake/images/124"
bookmark = "http://localhost/fake/images/124"
+ alternate = "%s/fake/images/124" % utils.generate_glance_url()
server_href = "http://localhost/v1.1/servers/42"
server_bookmark = "http://localhost/servers/42"
@@ -152,6 +155,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": bookmark,
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": alternate
}],
},
}
@@ -289,6 +297,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/123",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/123" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -303,6 +317,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/124",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/124" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -317,6 +337,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/125",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/125" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -331,6 +357,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/126",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/126" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -345,6 +377,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/127",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/127" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -359,6 +397,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/128",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/128" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -373,6 +417,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/129",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/129" %
+ utils.generate_glance_url()
+ },
],
},
{
@@ -387,6 +437,12 @@ class ImagesTest(test.TestCase):
"rel": "bookmark",
"href": "http://localhost/fake/images/130",
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/130" %
+ utils.generate_glance_url()
+ },
],
},
]
@@ -493,6 +549,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/123",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/123" % utils.generate_glance_url()
}],
},
{
@@ -524,6 +585,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/124",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/124" % utils.generate_glance_url()
}],
},
{
@@ -555,6 +621,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/125",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/125" % utils.generate_glance_url()
}],
},
{
@@ -586,6 +657,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/126",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/126" % utils.generate_glance_url()
}],
},
{
@@ -617,6 +693,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/127",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/127" % utils.generate_glance_url()
}],
},
{
@@ -648,6 +729,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/128",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/128" % utils.generate_glance_url()
}],
},
{
@@ -679,6 +765,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/129",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/129" % utils.generate_glance_url()
}],
},
{
@@ -696,6 +787,11 @@ class ImagesTest(test.TestCase):
{
"rel": "bookmark",
"href": "http://localhost/fake/images/130",
+ },
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": "%s/fake/images/130" % utils.generate_glance_url()
}],
},
]
@@ -963,6 +1059,12 @@ class ImagesTest(test.TestCase):
response = req.get_response(fakes.wsgi_app())
self.assertEqual(400, response.status_int)
+ def test_generate_alternate(self):
+ view = images_view.ViewBuilderV11(1)
+ generated_url = view.generate_alternate(1)
+ actual_url = "%s//images/1" % utils.generate_glance_url()
+ self.assertEqual(generated_url, actual_url)
+
class ImageXMLSerializationTest(test.TestCase):
diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py
index 1ba794a1a..19a15332d 100644
--- a/nova/tests/test_utils.py
+++ b/nova/tests/test_utils.py
@@ -20,10 +20,14 @@ import tempfile
import nova
from nova import exception
+from nova import flags
from nova import test
from nova import utils
+FLAGS = flags.FLAGS
+
+
class ExecuteTestCase(test.TestCase):
def test_retry_on_failure(self):
fd, tmpfilename = tempfile.mkstemp()
@@ -291,6 +295,11 @@ class GenericUtilsTestCase(test.TestCase):
self.assertFalse(utils.bool_from_str(None))
self.assertFalse(utils.bool_from_str('junk'))
+ def test_generate_glance_url(self):
+ generated_url = utils.generate_glance_url()
+ actual_url = "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
+ self.assertEqual(generated_url, actual_url)
+
class IsUUIDLikeTestCase(test.TestCase):
def assertUUIDLike(self, val, expected):