Fix the parameter order of assertEqual in glanceclient v2 test
On assertEqual, the order of parameters should be (expected, observed). But, some part of glanceclient v2 test were written with invalid order. This patch fixes this problem. Partially Close-bug: #1277104 Change-Id: Iae3fb9dda28b67a07f527b15ca83d9cca3e867d4
This commit is contained in:
@@ -33,12 +33,12 @@ class ClientTest(testtools.TestCase):
|
|||||||
|
|
||||||
def test_endpoint(self):
|
def test_endpoint(self):
|
||||||
gc = client.Client("http://example.com")
|
gc = client.Client("http://example.com")
|
||||||
self.assertEqual(gc.http_client.endpoint, "http://example.com")
|
self.assertEqual("http://example.com", gc.http_client.endpoint)
|
||||||
|
|
||||||
def test_versioned_endpoint(self):
|
def test_versioned_endpoint(self):
|
||||||
gc = client.Client("http://example.com/v2")
|
gc = client.Client("http://example.com/v2")
|
||||||
self.assertEqual(gc.http_client.endpoint, "http://example.com")
|
self.assertEqual("http://example.com", gc.http_client.endpoint)
|
||||||
|
|
||||||
def test_versioned_endpoint_with_minor_revision(self):
|
def test_versioned_endpoint_with_minor_revision(self):
|
||||||
gc = client.Client("http://example.com/v2.1")
|
gc = client.Client("http://example.com/v2.1")
|
||||||
self.assertEqual(gc.http_client.endpoint, "http://example.com")
|
self.assertEqual("http://example.com", gc.http_client.endpoint)
|
||||||
|
@@ -322,50 +322,50 @@ class TestController(testtools.TestCase):
|
|||||||
def test_list_images(self):
|
def test_list_images(self):
|
||||||
#NOTE(bcwaldon): cast to list since the controller returns a generator
|
#NOTE(bcwaldon): cast to list since the controller returns a generator
|
||||||
images = list(self.controller.list())
|
images = list(self.controller.list())
|
||||||
self.assertEqual(images[0].id, '3a4560a1-e585-443e-9b39-553b46ec92d1')
|
self.assertEqual('3a4560a1-e585-443e-9b39-553b46ec92d1', images[0].id)
|
||||||
self.assertEqual(images[0].name, 'image-1')
|
self.assertEqual('image-1', images[0].name)
|
||||||
self.assertEqual(images[1].id, '6f99bf80-2ee6-47cf-acfe-1f1fabb7e810')
|
self.assertEqual('6f99bf80-2ee6-47cf-acfe-1f1fabb7e810', images[1].id)
|
||||||
self.assertEqual(images[1].name, 'image-2')
|
self.assertEqual('image-2', images[1].name)
|
||||||
|
|
||||||
def test_list_images_paginated(self):
|
def test_list_images_paginated(self):
|
||||||
#NOTE(bcwaldon): cast to list since the controller returns a generator
|
#NOTE(bcwaldon): cast to list since the controller returns a generator
|
||||||
images = list(self.controller.list(page_size=1))
|
images = list(self.controller.list(page_size=1))
|
||||||
self.assertEqual(images[0].id, '3a4560a1-e585-443e-9b39-553b46ec92d1')
|
self.assertEqual('3a4560a1-e585-443e-9b39-553b46ec92d1', images[0].id)
|
||||||
self.assertEqual(images[0].name, 'image-1')
|
self.assertEqual('image-1', images[0].name)
|
||||||
self.assertEqual(images[1].id, '6f99bf80-2ee6-47cf-acfe-1f1fabb7e810')
|
self.assertEqual('6f99bf80-2ee6-47cf-acfe-1f1fabb7e810', images[1].id)
|
||||||
self.assertEqual(images[1].name, 'image-2')
|
self.assertEqual('image-2', images[1].name)
|
||||||
|
|
||||||
def test_list_images_visibility_public(self):
|
def test_list_images_visibility_public(self):
|
||||||
filters = {'filters': dict([('visibility', 'public')])}
|
filters = {'filters': dict([('visibility', 'public')])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _PUBLIC_ID)
|
self.assertEqual(_PUBLIC_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_visibility_private(self):
|
def test_list_images_visibility_private(self):
|
||||||
filters = {'filters': dict([('visibility', 'private')])}
|
filters = {'filters': dict([('visibility', 'private')])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _PRIVATE_ID)
|
self.assertEqual(_PRIVATE_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_visibility_shared(self):
|
def test_list_images_visibility_shared(self):
|
||||||
filters = {'filters': dict([('visibility', 'shared')])}
|
filters = {'filters': dict([('visibility', 'shared')])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _SHARED_ID)
|
self.assertEqual(_SHARED_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_member_status_rejected(self):
|
def test_list_images_member_status_rejected(self):
|
||||||
filters = {'filters': dict([('member_status', 'rejected')])}
|
filters = {'filters': dict([('member_status', 'rejected')])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _STATUS_REJECTED_ID)
|
self.assertEqual(_STATUS_REJECTED_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_for_owner(self):
|
def test_list_images_for_owner(self):
|
||||||
filters = {'filters': dict([('owner', _OWNER_ID)])}
|
filters = {'filters': dict([('owner', _OWNER_ID)])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _OWNED_IMAGE_ID)
|
self.assertEqual(_OWNED_IMAGE_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_for_checksum_single_image(self):
|
def test_list_images_for_checksum_single_image(self):
|
||||||
fake_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
fake_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
||||||
filters = {'filters': dict([('checksum', _CHKSUM)])}
|
filters = {'filters': dict([('checksum', _CHKSUM)])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(1, len(images))
|
self.assertEqual(1, len(images))
|
||||||
self.assertEqual(images[0].id, '%s' % fake_id)
|
self.assertEqual('%s' % fake_id, images[0].id)
|
||||||
|
|
||||||
def test_list_images_for_checksum_multiple_images(self):
|
def test_list_images_for_checksum_multiple_images(self):
|
||||||
fake_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
fake_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
||||||
@@ -373,8 +373,8 @@ class TestController(testtools.TestCase):
|
|||||||
filters = {'filters': dict([('checksum', _CHKSUM1)])}
|
filters = {'filters': dict([('checksum', _CHKSUM1)])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(2, len(images))
|
self.assertEqual(2, len(images))
|
||||||
self.assertEqual(images[0].id, '%s' % fake_id1)
|
self.assertEqual('%s' % fake_id1, images[0].id)
|
||||||
self.assertEqual(images[1].id, '%s' % fake_id2)
|
self.assertEqual('%s' % fake_id2, images[1].id)
|
||||||
|
|
||||||
def test_list_images_for_wrong_checksum(self):
|
def test_list_images_for_wrong_checksum(self):
|
||||||
filters = {'filters': dict([('checksum', 'wrong')])}
|
filters = {'filters': dict([('checksum', 'wrong')])}
|
||||||
@@ -384,14 +384,14 @@ class TestController(testtools.TestCase):
|
|||||||
def test_list_images_for_bogus_owner(self):
|
def test_list_images_for_bogus_owner(self):
|
||||||
filters = {'filters': dict([('owner', _BOGUS_ID)])}
|
filters = {'filters': dict([('owner', _BOGUS_ID)])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images, [])
|
self.assertEqual([], images)
|
||||||
|
|
||||||
def test_list_images_for_bunch_of_filters(self):
|
def test_list_images_for_bunch_of_filters(self):
|
||||||
filters = {'filters': dict([('owner', _BOGUS_ID),
|
filters = {'filters': dict([('owner', _BOGUS_ID),
|
||||||
('visibility', 'shared'),
|
('visibility', 'shared'),
|
||||||
('member_status', 'pending')])}
|
('member_status', 'pending')])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(images[0].id, _EVERYTHING_ID)
|
self.assertEqual(_EVERYTHING_ID, images[0].id)
|
||||||
|
|
||||||
def test_list_images_filters_encoding(self):
|
def test_list_images_filters_encoding(self):
|
||||||
filters = {"owner": u"ni\xf1o"}
|
filters = {"owner": u"ni\xf1o"}
|
||||||
@@ -404,14 +404,14 @@ class TestController(testtools.TestCase):
|
|||||||
# We just want to make sure filters are correctly encoded.
|
# We just want to make sure filters are correctly encoded.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertEqual(filters["owner"], "ni\xc3\xb1o")
|
self.assertEqual("ni\xc3\xb1o", filters["owner"])
|
||||||
|
|
||||||
def test_list_images_for_tag_single_image(self):
|
def test_list_images_for_tag_single_image(self):
|
||||||
img_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
img_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
||||||
filters = {'filters': dict([('tag', [_TAG1])])}
|
filters = {'filters': dict([('tag', [_TAG1])])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(1, len(images))
|
self.assertEqual(1, len(images))
|
||||||
self.assertEqual(images[0].id, '%s' % img_id)
|
self.assertEqual('%s' % img_id, images[0].id)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_list_images_for_tag_multiple_images(self):
|
def test_list_images_for_tag_multiple_images(self):
|
||||||
@@ -420,15 +420,15 @@ class TestController(testtools.TestCase):
|
|||||||
filters = {'filters': dict([('tag', [_TAG2])])}
|
filters = {'filters': dict([('tag', [_TAG2])])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(2, len(images))
|
self.assertEqual(2, len(images))
|
||||||
self.assertEqual(images[0].id, '%s' % img_id1)
|
self.assertEqual('%s' % img_id1, images[0].id)
|
||||||
self.assertEqual(images[1].id, '%s' % img_id2)
|
self.assertEqual('%s' % img_id2, images[1].id)
|
||||||
|
|
||||||
def test_list_images_for_multi_tags(self):
|
def test_list_images_for_multi_tags(self):
|
||||||
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
||||||
filters = {'filters': dict([('tag', [_TAG1, _TAG2])])}
|
filters = {'filters': dict([('tag', [_TAG1, _TAG2])])}
|
||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(1, len(images))
|
self.assertEqual(1, len(images))
|
||||||
self.assertEqual(images[0].id, '%s' % img_id1)
|
self.assertEqual('%s' % img_id1, images[0].id)
|
||||||
|
|
||||||
def test_list_images_for_non_existent_tag(self):
|
def test_list_images_for_non_existent_tag(self):
|
||||||
filters = {'filters': dict([('tag', ['fake'])])}
|
filters = {'filters': dict([('tag', ['fake'])])}
|
||||||
@@ -437,16 +437,16 @@ class TestController(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_image(self):
|
def test_get_image(self):
|
||||||
image = self.controller.get('3a4560a1-e585-443e-9b39-553b46ec92d1')
|
image = self.controller.get('3a4560a1-e585-443e-9b39-553b46ec92d1')
|
||||||
self.assertEqual(image.id, '3a4560a1-e585-443e-9b39-553b46ec92d1')
|
self.assertEqual('3a4560a1-e585-443e-9b39-553b46ec92d1', image.id)
|
||||||
self.assertEqual(image.name, 'image-1')
|
self.assertEqual('image-1', image.name)
|
||||||
|
|
||||||
def test_create_image(self):
|
def test_create_image(self):
|
||||||
properties = {
|
properties = {
|
||||||
'name': 'image-1'
|
'name': 'image-1'
|
||||||
}
|
}
|
||||||
image = self.controller.create(**properties)
|
image = self.controller.create(**properties)
|
||||||
self.assertEqual(image.id, '3a4560a1-e585-443e-9b39-553b46ec92d1')
|
self.assertEqual('3a4560a1-e585-443e-9b39-553b46ec92d1', image.id)
|
||||||
self.assertEqual(image.name, 'image-1')
|
self.assertEqual('image-1', image.name)
|
||||||
|
|
||||||
def test_create_bad_additionalProperty_type(self):
|
def test_create_bad_additionalProperty_type(self):
|
||||||
properties = {
|
properties = {
|
||||||
@@ -463,7 +463,7 @@ class TestController(testtools.TestCase):
|
|||||||
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a',
|
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a',
|
||||||
{},
|
{},
|
||||||
None)]
|
None)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
|
||||||
def test_data_upload(self):
|
def test_data_upload(self):
|
||||||
image_data = 'CCC'
|
image_data = 'CCC'
|
||||||
@@ -472,7 +472,7 @@ class TestController(testtools.TestCase):
|
|||||||
expect = [('PUT', '/v2/images/%s/file' % image_id,
|
expect = [('PUT', '/v2/images/%s/file' % image_id,
|
||||||
{'Content-Type': 'application/octet-stream'},
|
{'Content-Type': 'application/octet-stream'},
|
||||||
image_data)]
|
image_data)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
|
||||||
def test_data_upload_w_size(self):
|
def test_data_upload_w_size(self):
|
||||||
image_data = 'CCC'
|
image_data = 'CCC'
|
||||||
@@ -481,23 +481,23 @@ class TestController(testtools.TestCase):
|
|||||||
expect = [('PUT', '/v2/images/%s/file' % image_id,
|
expect = [('PUT', '/v2/images/%s/file' % image_id,
|
||||||
{'Content-Type': 'application/octet-stream'},
|
{'Content-Type': 'application/octet-stream'},
|
||||||
image_data, 3)]
|
image_data, 3)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
|
||||||
def test_data_without_checksum(self):
|
def test_data_without_checksum(self):
|
||||||
body = self.controller.data('5cc4bebc-db27-11e1-a1eb-080027cbe205',
|
body = self.controller.data('5cc4bebc-db27-11e1-a1eb-080027cbe205',
|
||||||
do_checksum=False)
|
do_checksum=False)
|
||||||
body = ''.join([b for b in body])
|
body = ''.join([b for b in body])
|
||||||
self.assertEqual(body, 'A')
|
self.assertEqual('A', body)
|
||||||
|
|
||||||
body = self.controller.data('5cc4bebc-db27-11e1-a1eb-080027cbe205')
|
body = self.controller.data('5cc4bebc-db27-11e1-a1eb-080027cbe205')
|
||||||
body = ''.join([b for b in body])
|
body = ''.join([b for b in body])
|
||||||
self.assertEqual(body, 'A')
|
self.assertEqual('A', body)
|
||||||
|
|
||||||
def test_data_with_wrong_checksum(self):
|
def test_data_with_wrong_checksum(self):
|
||||||
body = self.controller.data('66fb18d6-db27-11e1-a1eb-080027cbe205',
|
body = self.controller.data('66fb18d6-db27-11e1-a1eb-080027cbe205',
|
||||||
do_checksum=False)
|
do_checksum=False)
|
||||||
body = ''.join([b for b in body])
|
body = ''.join([b for b in body])
|
||||||
self.assertEqual(body, 'BB')
|
self.assertEqual('BB', body)
|
||||||
|
|
||||||
body = self.controller.data('66fb18d6-db27-11e1-a1eb-080027cbe205')
|
body = self.controller.data('66fb18d6-db27-11e1-a1eb-080027cbe205')
|
||||||
try:
|
try:
|
||||||
@@ -512,11 +512,11 @@ class TestController(testtools.TestCase):
|
|||||||
body = self.controller.data('1b1c6366-dd57-11e1-af0f-02163e68b1d8',
|
body = self.controller.data('1b1c6366-dd57-11e1-af0f-02163e68b1d8',
|
||||||
do_checksum=False)
|
do_checksum=False)
|
||||||
body = ''.join([b for b in body])
|
body = ''.join([b for b in body])
|
||||||
self.assertEqual(body, 'CCC')
|
self.assertEqual('CCC', body)
|
||||||
|
|
||||||
body = self.controller.data('1b1c6366-dd57-11e1-af0f-02163e68b1d8')
|
body = self.controller.data('1b1c6366-dd57-11e1-af0f-02163e68b1d8')
|
||||||
body = ''.join([b for b in body])
|
body = ''.join([b for b in body])
|
||||||
self.assertEqual(body, 'CCC')
|
self.assertEqual('CCC', body)
|
||||||
|
|
||||||
def test_update_replace_prop(self):
|
def test_update_replace_prop(self):
|
||||||
image_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
image_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
||||||
@@ -531,11 +531,11 @@ class TestController(testtools.TestCase):
|
|||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
('GET', '/v2/images/%s' % image_id, {}, None),
|
||||||
]
|
]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self.assertEqual(image.id, image_id)
|
self.assertEqual(image_id, image.id)
|
||||||
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual(image.name, 'image-1')
|
self.assertEqual('image-1', image.name)
|
||||||
|
|
||||||
def test_update_add_prop(self):
|
def test_update_add_prop(self):
|
||||||
image_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
image_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
|
||||||
@@ -550,11 +550,11 @@ class TestController(testtools.TestCase):
|
|||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
('GET', '/v2/images/%s' % image_id, {}, None),
|
||||||
]
|
]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self.assertEqual(image.id, image_id)
|
self.assertEqual(image_id, image.id)
|
||||||
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual(image.name, 'image-1')
|
self.assertEqual('image-1', image.name)
|
||||||
|
|
||||||
def test_update_remove_prop(self):
|
def test_update_remove_prop(self):
|
||||||
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
||||||
@@ -569,11 +569,11 @@ class TestController(testtools.TestCase):
|
|||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
('GET', '/v2/images/%s' % image_id, {}, None),
|
||||||
]
|
]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self.assertEqual(image.id, image_id)
|
self.assertEqual(image_id, image.id)
|
||||||
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual(image.name, 'image-3')
|
self.assertEqual('image-3', image.name)
|
||||||
|
|
||||||
def test_update_replace_remove_same_prop(self):
|
def test_update_replace_remove_same_prop(self):
|
||||||
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
||||||
@@ -591,11 +591,11 @@ class TestController(testtools.TestCase):
|
|||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
('GET', '/v2/images/%s' % image_id, {}, None),
|
||||||
]
|
]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self.assertEqual(image.id, image_id)
|
self.assertEqual(image_id, image.id)
|
||||||
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual(image.name, 'image-3')
|
self.assertEqual('image-3', image.name)
|
||||||
|
|
||||||
def test_update_add_remove_same_prop(self):
|
def test_update_add_remove_same_prop(self):
|
||||||
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
||||||
@@ -612,11 +612,11 @@ class TestController(testtools.TestCase):
|
|||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
('GET', '/v2/images/%s' % image_id, {}, None),
|
||||||
]
|
]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self.assertEqual(image.id, image_id)
|
self.assertEqual(image_id, image.id)
|
||||||
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
#NOTE(bcwaldon): due to limitations of our fake api framework, the name
|
||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual(image.name, 'image-3')
|
self.assertEqual('image-3', image.name)
|
||||||
|
|
||||||
def test_update_bad_additionalProperty_type(self):
|
def test_update_bad_additionalProperty_type(self):
|
||||||
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
||||||
|
@@ -77,8 +77,8 @@ class TestController(testtools.TestCase):
|
|||||||
image_id = IMAGE
|
image_id = IMAGE
|
||||||
#NOTE(iccha): cast to list since the controller returns a generator
|
#NOTE(iccha): cast to list since the controller returns a generator
|
||||||
image_members = list(self.controller.list(image_id))
|
image_members = list(self.controller.list(image_id))
|
||||||
self.assertEqual(image_members[0].image_id, IMAGE)
|
self.assertEqual(IMAGE, image_members[0].image_id)
|
||||||
self.assertEqual(image_members[0].member_id, MEMBER)
|
self.assertEqual(MEMBER, image_members[0].member_id)
|
||||||
|
|
||||||
def test_delete_image_member(self):
|
def test_delete_image_member(self):
|
||||||
image_id = IMAGE
|
image_id = IMAGE
|
||||||
@@ -90,22 +90,22 @@ class TestController(testtools.TestCase):
|
|||||||
mem=MEMBER),
|
mem=MEMBER),
|
||||||
{},
|
{},
|
||||||
None)]
|
None)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
|
||||||
def test_update_image_members(self):
|
def test_update_image_members(self):
|
||||||
image_id = IMAGE
|
image_id = IMAGE
|
||||||
member_id = MEMBER
|
member_id = MEMBER
|
||||||
status = 'accepted'
|
status = 'accepted'
|
||||||
image_member = self.controller.update(image_id, member_id, status)
|
image_member = self.controller.update(image_id, member_id, status)
|
||||||
self.assertEqual(image_member.image_id, IMAGE)
|
self.assertEqual(IMAGE, image_member.image_id)
|
||||||
self.assertEqual(image_member.member_id, MEMBER)
|
self.assertEqual(MEMBER, image_member.member_id)
|
||||||
self.assertEqual(image_member.status, status)
|
self.assertEqual(status, image_member.status)
|
||||||
|
|
||||||
def test_create_image_members(self):
|
def test_create_image_members(self):
|
||||||
image_id = IMAGE
|
image_id = IMAGE
|
||||||
member_id = MEMBER
|
member_id = MEMBER
|
||||||
status = 'pending'
|
status = 'pending'
|
||||||
image_member = self.controller.create(image_id, member_id)
|
image_member = self.controller.create(image_id, member_id)
|
||||||
self.assertEqual(image_member.image_id, IMAGE)
|
self.assertEqual(IMAGE, image_member.image_id)
|
||||||
self.assertEqual(image_member.member_id, MEMBER)
|
self.assertEqual(MEMBER, image_member.member_id)
|
||||||
self.assertEqual(image_member.status, status)
|
self.assertEqual(status, image_member.status)
|
||||||
|
@@ -62,31 +62,31 @@ def compare_json_patches(a, b):
|
|||||||
class TestSchemaProperty(testtools.TestCase):
|
class TestSchemaProperty(testtools.TestCase):
|
||||||
def test_property_minimum(self):
|
def test_property_minimum(self):
|
||||||
prop = schemas.SchemaProperty('size')
|
prop = schemas.SchemaProperty('size')
|
||||||
self.assertEqual(prop.name, 'size')
|
self.assertEqual('size', prop.name)
|
||||||
|
|
||||||
def test_property_description(self):
|
def test_property_description(self):
|
||||||
prop = schemas.SchemaProperty('size', description='some quantity')
|
prop = schemas.SchemaProperty('size', description='some quantity')
|
||||||
self.assertEqual(prop.name, 'size')
|
self.assertEqual('size', prop.name)
|
||||||
self.assertEqual(prop.description, 'some quantity')
|
self.assertEqual('some quantity', prop.description)
|
||||||
|
|
||||||
|
|
||||||
class TestSchema(testtools.TestCase):
|
class TestSchema(testtools.TestCase):
|
||||||
def test_schema_minimum(self):
|
def test_schema_minimum(self):
|
||||||
raw_schema = {'name': 'Country', 'properties': {}}
|
raw_schema = {'name': 'Country', 'properties': {}}
|
||||||
schema = schemas.Schema(raw_schema)
|
schema = schemas.Schema(raw_schema)
|
||||||
self.assertEqual(schema.name, 'Country')
|
self.assertEqual('Country', schema.name)
|
||||||
self.assertEqual(schema.properties, [])
|
self.assertEqual([], schema.properties)
|
||||||
|
|
||||||
def test_schema_with_property(self):
|
def test_schema_with_property(self):
|
||||||
raw_schema = {'name': 'Country', 'properties': {'size': {}}}
|
raw_schema = {'name': 'Country', 'properties': {'size': {}}}
|
||||||
schema = schemas.Schema(raw_schema)
|
schema = schemas.Schema(raw_schema)
|
||||||
self.assertEqual(schema.name, 'Country')
|
self.assertEqual('Country', schema.name)
|
||||||
self.assertEqual([p.name for p in schema.properties], ['size'])
|
self.assertEqual(['size'], [p.name for p in schema.properties])
|
||||||
|
|
||||||
def test_raw(self):
|
def test_raw(self):
|
||||||
raw_schema = {'name': 'Country', 'properties': {}}
|
raw_schema = {'name': 'Country', 'properties': {}}
|
||||||
schema = schemas.Schema(raw_schema)
|
schema = schemas.Schema(raw_schema)
|
||||||
self.assertEqual(schema.raw(), raw_schema)
|
self.assertEqual(raw_schema, schema.raw())
|
||||||
|
|
||||||
|
|
||||||
class TestController(testtools.TestCase):
|
class TestController(testtools.TestCase):
|
||||||
@@ -97,8 +97,8 @@ class TestController(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_schema(self):
|
def test_get_schema(self):
|
||||||
schema = self.controller.get('image')
|
schema = self.controller.get('image')
|
||||||
self.assertEqual(schema.name, 'image')
|
self.assertEqual('image', schema.name)
|
||||||
self.assertEqual([p.name for p in schema.properties], ['name'])
|
self.assertEqual(['name'], [p.name for p in schema.properties])
|
||||||
|
|
||||||
|
|
||||||
class TestSchemaBasedModel(testtools.TestCase):
|
class TestSchemaBasedModel(testtools.TestCase):
|
||||||
@@ -169,3 +169,4 @@ class TestSchemaBasedModel(testtools.TestCase):
|
|||||||
patch = original.patch
|
patch = original.patch
|
||||||
expected = '[{"path": "/color", "op": "remove"}]'
|
expected = '[{"path": "/color", "op": "remove"}]'
|
||||||
self.assertTrue(compare_json_patches(patch, expected))
|
self.assertTrue(compare_json_patches(patch, expected))
|
||||||
|
self.assertEqual(expected, patch)
|
||||||
|
@@ -61,7 +61,7 @@ class TestController(testtools.TestCase):
|
|||||||
tag_value=TAG),
|
tag_value=TAG),
|
||||||
{},
|
{},
|
||||||
None)]
|
None)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
|
||||||
def test_delete_image_tag(self):
|
def test_delete_image_tag(self):
|
||||||
image_id = IMAGE
|
image_id = IMAGE
|
||||||
@@ -73,4 +73,4 @@ class TestController(testtools.TestCase):
|
|||||||
tag_value=TAG),
|
tag_value=TAG),
|
||||||
{},
|
{},
|
||||||
None)]
|
None)]
|
||||||
self.assertEqual(self.api.calls, expect)
|
self.assertEqual(expect, self.api.calls)
|
||||||
|
Reference in New Issue
Block a user