Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected). The correct order expected by testtools is assertEqual(expected, observed). Change-Id: I83b7009f9b32f4abc88c23cafbe293b65dc25fb4 Partial-Bug: #1259292
This commit is contained in:
parent
450baeed4f
commit
ac404c4bcf
@ -38,8 +38,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
]
|
||||
response = nova.Keypairs().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"id": "one"}, {"id": "two"}]})
|
||||
self.assertEqual({"items": [{"id": "one"}, {"id": "two"}]},
|
||||
response.json)
|
||||
nc.keypair_list.assert_called_once_with(request)
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
@ -51,9 +51,9 @@ class NovaRestTestCase(test.TestCase):
|
||||
with mock.patch.object(settings, 'DEBUG', True):
|
||||
response = nova.Keypairs().post(request)
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response.json,
|
||||
{"name": "Ni!", "public_key": "sekrit"})
|
||||
self.assertEqual(response['location'], '/api/nova/keypairs/Ni%21')
|
||||
self.assertEqual({"name": "Ni!", "public_key": "sekrit"},
|
||||
response.json)
|
||||
self.assertEqual('/api/nova/keypairs/Ni%21', response['location'])
|
||||
nc.keypair_create.assert_called_once_with(request, 'Ni!')
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
@ -67,9 +67,9 @@ class NovaRestTestCase(test.TestCase):
|
||||
with mock.patch.object(settings, 'DEBUG', True):
|
||||
response = nova.Keypairs().post(request)
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response.json,
|
||||
{"name": "Ni!", "public_key": "hi"})
|
||||
self.assertEqual(response['location'], '/api/nova/keypairs/Ni%21')
|
||||
self.assertEqual({"name": "Ni!", "public_key": "hi"},
|
||||
response.json)
|
||||
self.assertEqual('/api/nova/keypairs/Ni%21', response['location'])
|
||||
nc.keypair_import.assert_called_once_with(request, 'Ni!', 'hi')
|
||||
|
||||
def test_keypair_create_and_download(self):
|
||||
@ -102,12 +102,12 @@ class NovaRestTestCase(test.TestCase):
|
||||
nc.keypair_create.assert_called_once_with(request, 'Ni!')
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(
|
||||
response['Content-Disposition'],
|
||||
'attachment; filename=ni.pem')
|
||||
'attachment; filename=ni.pem',
|
||||
response['Content-Disposition'])
|
||||
self.assertEqual(
|
||||
response.content.decode('utf-8'),
|
||||
"private key content")
|
||||
self.assertEqual(response['Content-Length'], '19')
|
||||
"private key content",
|
||||
response.content.decode('utf-8'))
|
||||
self.assertEqual('19', response['Content-Length'])
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
def test_keypair_fail_to_create_because_already_exists(self, nc):
|
||||
@ -119,7 +119,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
with mock.patch.object(settings, 'DEBUG', True):
|
||||
response = nova.Keypair().get(request, "Ni!")
|
||||
|
||||
self.assertEqual(response.status_code, 409)
|
||||
self.assertEqual(409, response.status_code)
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
def test_keypair_fail_to_create(self, nc):
|
||||
@ -131,7 +131,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
with mock.patch.object(settings, 'DEBUG', True):
|
||||
response = nova.Keypair().get(request, "Ni!")
|
||||
|
||||
self.assertEqual(response.status_code, 500)
|
||||
self.assertEqual(500, response.status_code)
|
||||
|
||||
#
|
||||
# Availability Zones
|
||||
@ -154,8 +154,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
]
|
||||
response = nova.AvailabilityZones().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"id": "one"}, {"id": "two"}]})
|
||||
self.assertEqual({"items": [{"id": "one"}, {"id": "two"}]},
|
||||
response.json)
|
||||
nc.availability_zone_list.assert_called_once_with(request, detail)
|
||||
|
||||
#
|
||||
@ -177,7 +177,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
response = nova.Limits().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
nc.tenant_absolute_limits.assert_called_once_with(request, reserved)
|
||||
self.assertEqual(response.json, {"id": "one"})
|
||||
self.assertEqual({"id": "one"}, response.json)
|
||||
|
||||
#
|
||||
# Servers
|
||||
@ -187,8 +187,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
request = self.mock_rest_request(body='''{"name": "hi"}''')
|
||||
response = nova.Servers().post(request)
|
||||
self.assertStatusCode(response, 400)
|
||||
self.assertEqual(response.json,
|
||||
"missing required parameter 'source_id'")
|
||||
self.assertEqual("missing required parameter 'source_id'",
|
||||
response.json)
|
||||
nc.server_create.assert_not_called()
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
@ -203,8 +203,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
new.id = 'server123'
|
||||
response = nova.Servers().post(request)
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response.json, {"id": "server123"})
|
||||
self.assertEqual(response['location'], '/api/nova/servers/server123')
|
||||
self.assertEqual({"id": "server123"}, response.json)
|
||||
self.assertEqual('/api/nova/servers/server123', response['location'])
|
||||
nc.server_create.assert_called_once_with(
|
||||
request, 'Ni!', 'image123', 'flavor123', 'sekrit', 'base64 yes',
|
||||
[{'name': 'root'}]
|
||||
@ -220,8 +220,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.Servers().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{'items': [{'id': 'one'}, {'id': 'two'}]})
|
||||
self.assertEqual({'items': [{'id': 'one'}, {'id': 'two'}]},
|
||||
response.json)
|
||||
nc.server_list.assert_called_once_with(request)
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
@ -246,8 +246,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.ServerGroups().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{'items': [{'id': '1'}, {'id': '2'}]})
|
||||
self.assertEqual({'items': [{'id': '1'}, {'id': '2'}]},
|
||||
response.json)
|
||||
nc.server_group_list.assert_called_once_with(request)
|
||||
|
||||
#
|
||||
@ -271,7 +271,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.ServerMetadata().patch(request, '1')
|
||||
self.assertStatusCode(response, 204)
|
||||
self.assertEqual(response.content, b'')
|
||||
self.assertEqual(b'', response.content)
|
||||
nc.server_metadata_update.assert_called_once_with(
|
||||
request, '1', {'a': '1', 'b': '2'}
|
||||
)
|
||||
@ -294,8 +294,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
]
|
||||
response = nova.Extensions().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"name": "foo"}, {"name": "bar"}]})
|
||||
self.assertEqual({"items": [{"name": "foo"}, {"name": "bar"}]},
|
||||
response.json)
|
||||
nc.list_extensions.assert_called_once_with(request)
|
||||
|
||||
#
|
||||
@ -347,7 +347,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
if get_extras:
|
||||
self.assertEqual(response.json, {"extras": {}, "name": "1"})
|
||||
else:
|
||||
self.assertEqual(response.json, {"name": "1"})
|
||||
self.assertEqual({"name": "1"}, response.json)
|
||||
nc.flavor_get.assert_called_once_with(request, "1",
|
||||
get_extras=get_extras)
|
||||
|
||||
@ -398,7 +398,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
response = nova.Flavors().post(request)
|
||||
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'], '/api/nova/flavors/123')
|
||||
self.assertEqual('/api/nova/flavors/123', response['location'])
|
||||
|
||||
nc.flavor_create.assert_called_once_with(request, **flavor_data)
|
||||
|
||||
@ -432,7 +432,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
response = nova.Flavors().post(request)
|
||||
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'], '/api/nova/flavors/1234')
|
||||
self.assertEqual('/api/nova/flavors/1234', response['location'])
|
||||
|
||||
nc.flavor_create.assert_called_once_with(request, **flavor_data)
|
||||
nc.add_tenant_to_flavor.assert_called_once_with(request, '1234', '1')
|
||||
@ -556,8 +556,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
]
|
||||
response = nova.Flavors().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"id": "1"}, {"id": "2"}]})
|
||||
self.assertEqual({"items": [{"id": "1"}, {"id": "2"}]},
|
||||
response.json)
|
||||
nc.flavor_list.assert_called_once_with(request, is_public=is_public,
|
||||
get_extras=False)
|
||||
|
||||
@ -586,12 +586,12 @@ class NovaRestTestCase(test.TestCase):
|
||||
response = nova.Flavors().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
if get_extras:
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"extras": {}, "id": "1"},
|
||||
{"extras": {}, "id": "2"}]})
|
||||
self.assertEqual({"items": [{"extras": {}, "id": "1"},
|
||||
{"extras": {}, "id": "2"}]},
|
||||
response.json)
|
||||
else:
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"id": "1"}, {"id": "2"}]})
|
||||
self.assertEqual({"items": [{"id": "1"}, {"id": "2"}]},
|
||||
response.json)
|
||||
nc.flavor_list.assert_called_once_with(request, is_public=None,
|
||||
get_extras=get_extras)
|
||||
|
||||
@ -621,7 +621,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.FlavorExtraSpecs().patch(request, '1')
|
||||
self.assertStatusCode(response, 204)
|
||||
self.assertEqual(response.content, b'')
|
||||
self.assertEqual(b'', response.content)
|
||||
nc.flavor_extra_set.assert_called_once_with(
|
||||
request, '1', {'a': '1', 'b': '2'}
|
||||
)
|
||||
@ -636,7 +636,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.AggregateExtraSpecs().get(request, "1")
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {"a": "1", "b": "2"})
|
||||
self.assertEqual({"a": "1", "b": "2"}, response.json)
|
||||
nc.aggregate_get.assert_called_once_with(request, "1")
|
||||
|
||||
@mock.patch.object(nova.api, 'nova')
|
||||
@ -647,7 +647,7 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.AggregateExtraSpecs().patch(request, '1')
|
||||
self.assertStatusCode(response, 204)
|
||||
self.assertEqual(response.content, b'')
|
||||
self.assertEqual(b'', response.content)
|
||||
nc.aggregate_set_metadata.assert_called_once_with(
|
||||
request, '1', {'a': '1', 'b': '2', 'c': None, 'd': None}
|
||||
)
|
||||
@ -670,8 +670,8 @@ class NovaRestTestCase(test.TestCase):
|
||||
|
||||
response = nova.Services().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.content.decode('utf-8'),
|
||||
'{"items": [{"id": "1"}, {"id": "2"}]}')
|
||||
self.assertEqual('{"items": [{"id": "1"}, {"id": "2"}]}',
|
||||
response.content.decode('utf-8'))
|
||||
nc.service_list.assert_called_once_with(request)
|
||||
|
||||
@test.create_stubs({api.base: ('is_service_enabled',)})
|
||||
|
@ -500,14 +500,14 @@ class ComputeApiTests(test.APITestCase):
|
||||
flavor.disk)
|
||||
|
||||
self.assertIsInstance(api_flavor, type(flavor))
|
||||
self.assertEqual(api_flavor.name, flavor.name)
|
||||
self.assertEqual(api_flavor.ram, flavor.ram)
|
||||
self.assertEqual(api_flavor.vcpus, flavor.vcpus)
|
||||
self.assertEqual(api_flavor.disk, flavor.disk)
|
||||
self.assertEqual(api_flavor.ephemeral, 0)
|
||||
self.assertEqual(api_flavor.swap, 0)
|
||||
self.assertEqual(api_flavor.is_public, True)
|
||||
self.assertEqual(api_flavor.rxtx_factor, 1)
|
||||
self.assertEqual(flavor.name, api_flavor.name)
|
||||
self.assertEqual(flavor.ram, api_flavor.ram)
|
||||
self.assertEqual(flavor.vcpus, api_flavor.vcpus)
|
||||
self.assertEqual(flavor.disk, api_flavor.disk)
|
||||
self.assertEqual(0, api_flavor.ephemeral)
|
||||
self.assertEqual(0, api_flavor.swap)
|
||||
self.assertEqual(True, api_flavor.is_public)
|
||||
self.assertEqual(1, api_flavor.rxtx_factor)
|
||||
|
||||
def test_flavor_delete(self):
|
||||
flavor = self.flavors.first()
|
||||
|
@ -23,7 +23,7 @@ class PolicyRestTestCase(test.TestCase):
|
||||
request = self.mock_rest_request(body=body)
|
||||
response = policy.Policy().post(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {"allowed": True})
|
||||
self.assertEqual({"allowed": True}, response.json)
|
||||
|
||||
@override_settings(POLICY_CHECK_FUNCTION=policy_backend.check)
|
||||
def test_rule_alone(self):
|
||||
@ -57,7 +57,7 @@ class PolicyRestTestCase(test.TestCase):
|
||||
body='''{"rules": [["compute", "compute:unlock_override"]]}''')
|
||||
response = policy.Policy().post(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {"allowed": False})
|
||||
self.assertEqual({"allowed": False}, response.json)
|
||||
|
||||
@override_settings(POLICY_CHECK_FUNCTION=policy_backend.check)
|
||||
def test_policy_error(self):
|
||||
@ -75,4 +75,4 @@ class AdminPolicyRestTestCase(test.BaseAdminViewTests):
|
||||
request = self.mock_rest_request(body=body)
|
||||
response = policy.Policy().post(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {"allowed": True})
|
||||
self.assertEqual({"allowed": True}, response.json)
|
||||
|
@ -25,7 +25,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
response = f(None, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, "ok")
|
||||
self.assertEqual("ok", response.json)
|
||||
|
||||
def test_api_success_no_auth_ok(self):
|
||||
@utils.ajax(authenticated=False)
|
||||
@ -35,7 +35,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
response = f(None, request)
|
||||
request.user.is_authenticated.assert_not_called()
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, "ok")
|
||||
self.assertEqual("ok", response.json)
|
||||
|
||||
def test_api_auth_required(self):
|
||||
@utils.ajax()
|
||||
@ -47,7 +47,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
response = f(None, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 401)
|
||||
self.assertEqual(response.json, "not logged in")
|
||||
self.assertEqual("not logged in", response.json)
|
||||
|
||||
def test_api_success_204(self):
|
||||
@utils.ajax()
|
||||
@ -56,7 +56,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
request = self.mock_rest_request()
|
||||
response = f(None, request)
|
||||
self.assertStatusCode(response, 204)
|
||||
self.assertEqual(response.content, b'')
|
||||
self.assertEqual(b'', response.content)
|
||||
|
||||
def test_api_error(self):
|
||||
@utils.ajax()
|
||||
@ -65,7 +65,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
request = self.mock_rest_request()
|
||||
response = f(None, request)
|
||||
self.assertStatusCode(response, 500)
|
||||
self.assertEqual(response.json, "b0rk")
|
||||
self.assertEqual("b0rk", response.json)
|
||||
|
||||
def test_api_malformed_json(self):
|
||||
@utils.ajax()
|
||||
@ -83,7 +83,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
request = self.mock_rest_request()
|
||||
response = f(None, request)
|
||||
self.assertStatusCode(response, 404)
|
||||
self.assertEqual(response.json, "b0rk")
|
||||
self.assertEqual("b0rk", response.json)
|
||||
|
||||
def test_data_required_with_no_data(self):
|
||||
@utils.ajax(data_required=True)
|
||||
@ -92,7 +92,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
request = self.mock_rest_request()
|
||||
response = f(None, request)
|
||||
self.assertStatusCode(response, 400)
|
||||
self.assertEqual(response.json, "request requires JSON body")
|
||||
self.assertEqual("request requires JSON body", response.json)
|
||||
|
||||
def test_valid_data_required(self):
|
||||
@utils.ajax(data_required=True)
|
||||
@ -103,7 +103,7 @@ class RestUtilsTestCase(test.TestCase):
|
||||
'''})
|
||||
response = f(None, request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, "OK")
|
||||
self.assertEqual("OK", response.json)
|
||||
|
||||
def test_api_created_response(self):
|
||||
@utils.ajax()
|
||||
@ -113,8 +113,8 @@ class RestUtilsTestCase(test.TestCase):
|
||||
response = f(None, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'], '/api/spam/spam123')
|
||||
self.assertEqual(response.content, b'')
|
||||
self.assertEqual('/api/spam/spam123', response['location'])
|
||||
self.assertEqual(b'', response.content)
|
||||
|
||||
def test_api_created_response_content(self):
|
||||
@utils.ajax()
|
||||
@ -124,8 +124,8 @@ class RestUtilsTestCase(test.TestCase):
|
||||
response = f(None, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'], '/api/spam/spam123')
|
||||
self.assertEqual(response.json, "spam!")
|
||||
self.assertEqual('/api/spam/spam123', response['location'])
|
||||
self.assertEqual("spam!", response.json)
|
||||
|
||||
def test_parse_filters_keywords(self):
|
||||
kwargs = {
|
||||
@ -187,8 +187,8 @@ class JSONEncoderTestCase(test.TestCase):
|
||||
response = f(self, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response['content-type'], 'application/json')
|
||||
self.assertEqual(response.content, b'NaN')
|
||||
self.assertEqual('application/json', response['content-type'])
|
||||
self.assertEqual(b'NaN', response.content)
|
||||
|
||||
def test_custom_encoder_on_infinity(self):
|
||||
@utils.ajax(json_encoder=json_encoder.NaNJSONEncoder)
|
||||
@ -199,8 +199,8 @@ class JSONEncoderTestCase(test.TestCase):
|
||||
response = f(self, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response['content-type'], 'application/json')
|
||||
self.assertEqual(response.content, b'1e+999')
|
||||
self.assertEqual('application/json', response['content-type'])
|
||||
self.assertEqual(b'1e+999', response.content)
|
||||
|
||||
def test_custom_encoder_on_negative_infinity(self):
|
||||
@utils.ajax(json_encoder=json_encoder.NaNJSONEncoder)
|
||||
@ -211,8 +211,8 @@ class JSONEncoderTestCase(test.TestCase):
|
||||
response = f(self, request)
|
||||
request.user.is_authenticated.assert_called_once_with()
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response['content-type'], 'application/json')
|
||||
self.assertEqual(response.content, b'-1e+999')
|
||||
self.assertEqual('application/json', response['content-type'])
|
||||
self.assertEqual(b'-1e+999', response.content)
|
||||
|
||||
def test_custom_encoder_yields_standard_json_for_conventional_data(self):
|
||||
@utils.ajax()
|
||||
|
@ -40,9 +40,8 @@ class SwiftRestTestCase(test.TestCase):
|
||||
nc.swift_get_capabilities.return_value = {'swift': {'version': '1.0'}}
|
||||
response = swift.Info().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {
|
||||
'info': {'swift': {'version': '1.0'}}
|
||||
})
|
||||
self.assertEqual({'info': {'swift': {'version': '1.0'}}},
|
||||
response.json)
|
||||
nc.swift_get_capabilities.assert_called_once_with(request)
|
||||
|
||||
#
|
||||
@ -54,9 +53,9 @@ class SwiftRestTestCase(test.TestCase):
|
||||
nc.swift_get_containers.return_value = (self._containers, False)
|
||||
response = swift.Containers().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json['items'][0]['name'],
|
||||
u'container one%\u6346')
|
||||
self.assertEqual(response.json['has_more'], False)
|
||||
self.assertEqual(u'container one%\u6346',
|
||||
response.json['items'][0]['name'])
|
||||
self.assertEqual(False, response.json['has_more'])
|
||||
nc.swift_get_containers.assert_called_once_with(request)
|
||||
|
||||
#
|
||||
@ -77,8 +76,8 @@ class SwiftRestTestCase(test.TestCase):
|
||||
request = self.mock_rest_request(body='{}')
|
||||
response = swift.Container().post(request, 'spam')
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'],
|
||||
u'/api/swift/containers/spam')
|
||||
self.assertEqual(u'/api/swift/containers/spam',
|
||||
response['location'])
|
||||
nc.swift_create_container.assert_called_once_with(
|
||||
request, 'spam', metadata={}
|
||||
)
|
||||
@ -88,8 +87,8 @@ class SwiftRestTestCase(test.TestCase):
|
||||
request = self.mock_rest_request(body='{"is_public": false}')
|
||||
response = swift.Container().post(request, 'spam')
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'],
|
||||
u'/api/swift/containers/spam')
|
||||
self.assertEqual(u'/api/swift/containers/spam',
|
||||
response['location'])
|
||||
nc.swift_create_container.assert_called_once_with(
|
||||
request, 'spam', metadata={'is_public': False}
|
||||
)
|
||||
@ -123,21 +122,21 @@ class SwiftRestTestCase(test.TestCase):
|
||||
)
|
||||
response = swift.Objects().get(request, u'container one%\u6346')
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(len(response.json['items']), 5)
|
||||
self.assertEqual(response.json['items'][3]['path'],
|
||||
u'test folder%\u6346/test.txt')
|
||||
self.assertEqual(response.json['items'][3]['name'], 'test.txt')
|
||||
self.assertEqual(response.json['items'][3]['is_object'], True)
|
||||
self.assertEqual(response.json['items'][3]['is_subdir'], False)
|
||||
self.assertEqual(response.json['items'][3]['path'],
|
||||
u'test folder%\u6346/test.txt')
|
||||
self.assertEqual(5, len(response.json['items']))
|
||||
self.assertEqual(u'test folder%\u6346/test.txt',
|
||||
response.json['items'][3]['path'])
|
||||
self.assertEqual('test.txt', response.json['items'][3]['name'])
|
||||
self.assertEqual(True, response.json['items'][3]['is_object'])
|
||||
self.assertEqual(False, response.json['items'][3]['is_subdir'])
|
||||
self.assertEqual(u'test folder%\u6346/test.txt',
|
||||
response.json['items'][3]['path'])
|
||||
|
||||
self.assertEqual(response.json['items'][4]['path'],
|
||||
u'test folder%\u6346/')
|
||||
self.assertEqual(response.json['items'][4]['name'],
|
||||
u'test folder%\u6346')
|
||||
self.assertEqual(response.json['items'][4]['is_object'], False)
|
||||
self.assertEqual(response.json['items'][4]['is_subdir'], True)
|
||||
self.assertEqual(u'test folder%\u6346/',
|
||||
response.json['items'][4]['path'])
|
||||
self.assertEqual(u'test folder%\u6346',
|
||||
response.json['items'][4]['name'])
|
||||
self.assertEqual(False, response.json['items'][4]['is_object'])
|
||||
self.assertEqual(True, response.json['items'][4]['is_subdir'])
|
||||
|
||||
nc.swift_get_objects.assert_called_once_with(request,
|
||||
u'container one%\u6346',
|
||||
@ -149,9 +148,9 @@ class SwiftRestTestCase(test.TestCase):
|
||||
nc.swift_get_objects.return_value = (self._subfolder, False)
|
||||
response = swift.Objects().get(request, u'container one%\u6346')
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(len(response.json['items']), 1)
|
||||
self.assertEqual(response.json['items'][0]['is_object'], True)
|
||||
self.assertEqual(response.json['items'][0]['is_subdir'], False)
|
||||
self.assertEqual(1, len(response.json['items']))
|
||||
self.assertEqual(True, response.json['items'][0]['is_object'])
|
||||
self.assertEqual(False, response.json['items'][0]['is_subdir'])
|
||||
nc.swift_get_objects.assert_called_once_with(
|
||||
request,
|
||||
u'container one%\u6346', prefix=u'test folder%\u6346/'
|
||||
@ -197,9 +196,9 @@ class SwiftRestTestCase(test.TestCase):
|
||||
response = swift.Object().post(request, 'spam', real_name)
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(
|
||||
response['location'],
|
||||
'=?utf-8?q?/api/swift/containers/spam/object/test_object'
|
||||
'=25=E6=8D=86?='
|
||||
'=25=E6=8D=86?=',
|
||||
response['location']
|
||||
)
|
||||
self.assertTrue(nc.swift_upload_object.called)
|
||||
call = nc.swift_upload_object.call_args[0]
|
||||
|
@ -63,22 +63,22 @@ class TestFloatingipAssociateDisassociate(helpers.TestCase):
|
||||
floatingip_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertTrue(floatingip_page.is_floatingip_present(floating_ip))
|
||||
|
||||
self.assertEqual(floatingip_page.get_fixed_ip(floating_ip), '-')
|
||||
self.assertEqual('-', floatingip_page.get_fixed_ip(floating_ip))
|
||||
floatingip_page.associate_floatingip(floating_ip, instance_name,
|
||||
instance_ipv4)
|
||||
self.assertTrue(
|
||||
floatingip_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
floatingip_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertEqual(floatingip_page.get_fixed_ip(floating_ip),
|
||||
instance_info)
|
||||
self.assertEqual(instance_info,
|
||||
floatingip_page.get_fixed_ip(floating_ip))
|
||||
|
||||
floatingip_page.disassociate_floatingip(floating_ip)
|
||||
self.assertTrue(
|
||||
floatingip_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertFalse(
|
||||
floatingip_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertEqual(floatingip_page.get_fixed_ip(floating_ip), '-')
|
||||
self.assertEqual('-', floatingip_page.get_fixed_ip(floating_ip))
|
||||
|
||||
floatingip_page.release_floatingip(floating_ip)
|
||||
self.assertTrue(
|
||||
|
@ -49,16 +49,16 @@ class UtilsMeteringTests(test.TestCase):
|
||||
"2012-04-11", "2012-04-12", "other")
|
||||
self.assertTrue(type(date_from) is datetime.datetime)
|
||||
self.assertTrue(type(date_to) is datetime.datetime)
|
||||
self.assertEqual(str(date_from.tzinfo), "UTC")
|
||||
self.assertEqual(str(date_to.tzinfo), "UTC")
|
||||
self.assertEqual("UTC", str(date_from.tzinfo))
|
||||
self.assertEqual("UTC", str(date_to.tzinfo))
|
||||
|
||||
def test_calc_date_args_datetime_dates(self):
|
||||
date_from, date_to = metering.calc_date_args(
|
||||
datetime.date(2012, 4, 11), datetime.date(2012, 4, 12), "other")
|
||||
self.assertTrue(type(date_from) is datetime.datetime)
|
||||
self.assertTrue(type(date_to) is datetime.datetime)
|
||||
self.assertEqual(str(date_from.tzinfo), "UTC")
|
||||
self.assertEqual(str(date_to.tzinfo), "UTC")
|
||||
self.assertEqual("UTC", str(date_from.tzinfo))
|
||||
self.assertEqual("UTC", str(date_to.tzinfo))
|
||||
|
||||
def test_calc_date_args_invalid(self):
|
||||
self.assertRaises(
|
||||
|
Loading…
Reference in New Issue
Block a user