Fix order of arguments in assertEqual

Some tests used incorrect order of arguments in assertEqual.
The correct order expected by testtools is
assertEqual(expected, observed).

Change-Id: I210ce20cb9427799219e8aedb9ee3282dea53d3f
Closes-Bug: #1259292
This commit is contained in:
Tetiana Lashchova 2015-09-29 15:20:16 +03:00
parent a01daba99f
commit 38513f7dc5
16 changed files with 137 additions and 139 deletions

View File

@ -145,7 +145,7 @@ class TestCaseShell(testtools.TestCase):
def test_package_is_not_provided(self): def test_package_is_not_provided(self):
_, stderr = self.shell(exitcode=1) _, stderr = self.shell(exitcode=1)
self.assertEqual(stderr, 'ERROR: Package name is required parameter.') self.assertEqual('ERROR: Package name is required parameter.', stderr)
def test_wrong_parent(self): def test_wrong_parent(self):
_, stderr = self.shell( _, stderr = self.shell(

View File

@ -126,8 +126,8 @@ class TestActionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
response = request.get_response(self.api) response = request.get_response(self.api)
self.assertEqual(response.status_code, 200) self.assertEqual(200, response.status_code)
self.assertEqual(response.json, expected_result) self.assertEqual(expected_result, response.json)
def test_get_result_not_found(self, _): def test_get_result_not_found(self, _):
"""If task does not exists, it should be handled correctly """If task does not exists, it should be handled correctly
@ -150,4 +150,4 @@ class TestActionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
response = request.get_response(self.api) response = request.get_response(self.api)
self.assertEqual(response.status_code, 404) self.assertEqual(404, response.status_code)

View File

@ -67,41 +67,41 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'False', '/v1/catalog/packages/', params={'catalog': 'False',
'owned': 'False'})) 'owned': 'False'}))
self.assertEqual(len(result['packages']), 4) self.assertEqual(4, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'False', '/v1/catalog/packages/', params={'catalog': 'False',
'owned': 'True'})) 'owned': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True', '/v1/catalog/packages/', params={'catalog': 'True',
'owned': 'False'})) 'owned': 'False'}))
self.assertEqual(len(result['packages']), 3) self.assertEqual(3, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True', '/v1/catalog/packages/', params={'catalog': 'True',
'owned': 'True'})) 'owned': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'owned': 'True', 'owned': 'True',
'fqn': pkg.fully_qualified_name})) 'fqn': pkg.fully_qualified_name}))
self.assertEqual(len(result['packages']), 1) self.assertEqual(1, len(result['packages']))
self.assertEqual(result['packages'][0]['fully_qualified_name'], self.assertEqual(pkg.fully_qualified_name,
pkg.fully_qualified_name) result['packages'][0]['fully_qualified_name'])
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'owned': 'True', 'owned': 'True',
'type': 'Library'})) 'type': 'Library'}))
self.assertEqual(len(result['packages']), 1) self.assertEqual(1, len(result['packages']))
self.assertEqual(result['packages'][0]['fully_qualified_name'], self.assertEqual(pkg.fully_qualified_name,
pkg.fully_qualified_name) result['packages'][0]['fully_qualified_name'])
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'type': 'Library'})) 'type': 'Library'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
def test_packages_filtering_non_admin(self): def test_packages_filtering_non_admin(self):
self.is_admin = False self.is_admin = False
@ -121,46 +121,46 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'False', '/v1/catalog/packages/', params={'catalog': 'False',
'owned': 'False'})) 'owned': 'False'}))
self.assertEqual(len(result['packages']), 3) self.assertEqual(3, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'False', '/v1/catalog/packages/', params={'catalog': 'False',
'owned': 'True'})) 'owned': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True', '/v1/catalog/packages/', params={'catalog': 'True',
'owned': 'False'})) 'owned': 'False'}))
self.assertEqual(len(result['packages']), 3) self.assertEqual(3, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True', '/v1/catalog/packages/', params={'catalog': 'True',
'owned': 'True'})) 'owned': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'owned': 'True', 'owned': 'True',
'fqn': pkg.fully_qualified_name})) 'fqn': pkg.fully_qualified_name}))
self.assertEqual(len(result['packages']), 1) self.assertEqual(1, len(result['packages']))
self.assertEqual(result['packages'][0]['fully_qualified_name'], self.assertEqual(pkg.fully_qualified_name,
pkg.fully_qualified_name) result['packages'][0]['fully_qualified_name'])
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'owned': 'True', 'owned': 'True',
'type': 'Library'})) 'type': 'Library'}))
self.assertEqual(len(result['packages']), 1) self.assertEqual(1, len(result['packages']))
self.assertEqual(result['packages'][0]['fully_qualified_name'], self.assertEqual(pkg.fully_qualified_name,
pkg.fully_qualified_name) result['packages'][0]['fully_qualified_name'])
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={ '/v1/catalog/packages/', params={
'type': 'Library'})) 'type': 'Library'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
self._set_policy_rules({'get_package': '', self._set_policy_rules({'get_package': '',
'manage_public_package': '!'}) 'manage_public_package': '!'})
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'False'})) '/v1/catalog/packages/', params={'catalog': 'False'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
def test_packages(self): def test_packages(self):
self._set_policy_rules( self._set_policy_rules(
@ -171,7 +171,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.expect_policy_check('get_package') self.expect_policy_check('get_package')
self.expect_policy_check('manage_public_package') self.expect_policy_check('manage_public_package')
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
self.assertEqual(len(result['packages']), 0) self.assertEqual(0, len(result['packages']))
self._add_pkg('test_tenant') self._add_pkg('test_tenant')
self._add_pkg('test_tenant') self._add_pkg('test_tenant')
@ -181,20 +181,20 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
# non-admin should only see 2 pkgs he can edit. # non-admin should only see 2 pkgs he can edit.
self.is_admin = False self.is_admin = False
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
# can only deploy his + public # can only deploy his + public
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True'})) '/v1/catalog/packages/', params={'catalog': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
# admin can edit anything # admin can edit anything
self.is_admin = True self.is_admin = True
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
self.assertEqual(len(result['packages']), 4) self.assertEqual(4, len(result['packages']))
# admin can only deploy his + public # admin can only deploy his + public
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True'})) '/v1/catalog/packages/', params={'catalog': 'True'}))
self.assertEqual(len(result['packages']), 2) self.assertEqual(2, len(result['packages']))
self._add_pkg('test_tenant', public=True) self._add_pkg('test_tenant', public=True)
self._add_pkg('other_tenant', public=True) self._add_pkg('other_tenant', public=True)
@ -202,20 +202,20 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
# non-admin are allowed to edit public packages by policy # non-admin are allowed to edit public packages by policy
self.is_admin = False self.is_admin = False
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
self.assertEqual(len(result['packages']), 4) self.assertEqual(4, len(result['packages']))
# can deploy mine + other public # can deploy mine + other public
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True'})) '/v1/catalog/packages/', params={'catalog': 'True'}))
self.assertEqual(len(result['packages']), 4) self.assertEqual(4, len(result['packages']))
# admin can edit anything # admin can edit anything
self.is_admin = True self.is_admin = True
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
self.assertEqual(len(result['packages']), 6) self.assertEqual(6, len(result['packages']))
# can deploy mine + public # can deploy mine + public
result = self.controller.search(self._get( result = self.controller.search(self._get(
'/v1/catalog/packages/', params={'catalog': 'True'})) '/v1/catalog/packages/', params={'catalog': 'True'}))
self.assertEqual(len(result['packages']), 4) self.assertEqual(4, len(result['packages']))
def _test_package(self): def _test_package(self):
package_dir = os.path.abspath( package_dir = os.path.abspath(
@ -266,7 +266,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
) )
result = self.controller.get_supplier_logo(req, saved_package.id) result = self.controller.get_supplier_logo(req, saved_package.id)
self.assertEqual(imghdr.what('', result), 'png') self.assertEqual('png', imghdr.what('', result))
def test_download_package(self): def test_download_package(self):
self._set_policy_rules( self._set_policy_rules(

View File

@ -85,4 +85,4 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
response = request.get_response(self.api) response = request.get_response(self.api)
# Should be forbidden! # Should be forbidden!
self.assertEqual(response.status_code, 403) self.assertEqual(403, response.status_code)

View File

@ -22,27 +22,27 @@ class TokenSanitizerTests(base.MuranoTestCase):
def test_dict_with_one_value(self): def test_dict_with_one_value(self):
source = {'token': 'value'} source = {'token': 'value'}
value = self.sanitizer.sanitize(source) value = self.sanitizer.sanitize(source)
self.assertEqual(value['token'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['token'])
def test_dict_with_few_value(self): def test_dict_with_few_value(self):
source = {'token': 'value', 'pass': 'value', 'TrustId': 'value'} source = {'token': 'value', 'pass': 'value', 'TrustId': 'value'}
value = self.sanitizer.sanitize(source) value = self.sanitizer.sanitize(source)
self.assertEqual(value['token'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['token'])
self.assertEqual(value['pass'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['pass'])
self.assertEqual(value['TrustId'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['TrustId'])
def test_dict_with_nested_dict(self): def test_dict_with_nested_dict(self):
source = {'obj': {'pass': 'value'}} source = {'obj': {'pass': 'value'}}
value = self.sanitizer.sanitize(source) value = self.sanitizer.sanitize(source)
self.assertEqual(value['obj']['pass'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['obj']['pass'])
def test_dict_with_nested_list(self): def test_dict_with_nested_list(self):
source = {'obj': [{'pass': 'value'}]} source = {'obj': [{'pass': 'value'}]}
value = self.sanitizer.sanitize(source) value = self.sanitizer.sanitize(source)
self.assertEqual(value['obj'][0]['pass'], self.sanitizer.message) self.assertEqual(self.sanitizer.message, value['obj'][0]['pass'])
def test_leave_out_other_values(self): def test_leave_out_other_values(self):
source = {'obj': ['value']} source = {'obj': ['value']}
value = self.sanitizer.sanitize(source) value = self.sanitizer.sanitize(source)
self.assertEqual(value['obj'][0], 'value') self.assertEqual('value', value['obj'][0])

View File

@ -30,17 +30,17 @@ class TraverseHelperTests(base.MuranoTestCase):
def test_root_get_with_value_type(self): def test_root_get_with_value_type(self):
source = 'source' source = 'source'
value = utils.TraverseHelper.get('/', source) value = utils.TraverseHelper.get('/', source)
self.assertEqual(value, source) self.assertEqual(source, value)
def test_attribute_get(self): def test_attribute_get(self):
source = {'attr': True} source = {'attr': True}
value = utils.TraverseHelper.get('/attr', source) value = utils.TraverseHelper.get('/attr', source)
self.assertEqual(value, True) self.assertEqual(True, value)
def test_nested_attribute_get(self): def test_nested_attribute_get(self):
source = {'obj': {'attr': True}} source = {'obj': {'attr': True}}
value = utils.TraverseHelper.get('/obj/attr', source) value = utils.TraverseHelper.get('/obj/attr', source)
self.assertEqual(value, True) self.assertEqual(True, value)
def test_list_item_attribute_get(self): def test_list_item_attribute_get(self):
source = {'obj': [ source = {'obj': [
@ -48,7 +48,7 @@ class TraverseHelperTests(base.MuranoTestCase):
{'?': {'id': '2s'}, 'value': 2}, {'?': {'id': '2s'}, 'value': 2},
]} ]}
value = utils.TraverseHelper.get('/obj/2s/value', source) value = utils.TraverseHelper.get('/obj/2s/value', source)
self.assertEqual(value, 2) self.assertEqual(2, value)
def test_list_item_attribute_get_by_index(self): def test_list_item_attribute_get_by_index(self):
source = {'obj': [ source = {'obj': [
@ -56,25 +56,25 @@ class TraverseHelperTests(base.MuranoTestCase):
{'?': {'id': 'guid2'}, 'value': 2} {'?': {'id': 'guid2'}, 'value': 2}
]} ]}
value = utils.TraverseHelper.get('/obj/1/value', source) value = utils.TraverseHelper.get('/obj/1/value', source)
self.assertEqual(value, 2) self.assertEqual(2, value)
def test_attribute_set(self): def test_attribute_set(self):
source = {'attr': True} source = {'attr': True}
utils.TraverseHelper.update('/newAttr', False, source) utils.TraverseHelper.update('/newAttr', False, source)
value = utils.TraverseHelper.get('/newAttr', source) value = utils.TraverseHelper.get('/newAttr', source)
self.assertEqual(value, False) self.assertEqual(False, value)
def test_attribute_update(self): def test_attribute_update(self):
source = {'attr': True} source = {'attr': True}
utils.TraverseHelper.update('/attr', False, source) utils.TraverseHelper.update('/attr', False, source)
value = utils.TraverseHelper.get('/attr', source) value = utils.TraverseHelper.get('/attr', source)
self.assertEqual(value, False) self.assertEqual(False, value)
def test_nested_attribute_update(self): def test_nested_attribute_update(self):
source = {'obj': {'attr': True}} source = {'obj': {'attr': True}}
utils.TraverseHelper.update('/obj/attr', False, source) utils.TraverseHelper.update('/obj/attr', False, source)
value = utils.TraverseHelper.get('/obj/attr', source) value = utils.TraverseHelper.get('/obj/attr', source)
self.assertEqual(value, False) self.assertEqual(False, value)
def test_adding_item_to_list(self): def test_adding_item_to_list(self):
source = {'attr': [1, 2, 3]} source = {'attr': [1, 2, 3]}

View File

@ -34,7 +34,7 @@ class TestCoreServices(base.MuranoTestCase):
template_services_mock.get_description.return_value = \ template_services_mock.get_description.return_value = \
fixture.environment_template_desc fixture.environment_template_desc
template_des = self.core_services.get_template_data('any', '/services') template_des = self.core_services.get_template_data('any', '/services')
self.assertEqual(template_des, []) self.assertEqual([], template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')
@mock.patch('murano.db.services.environment_templates.EnvTemplateServices') @mock.patch('murano.db.services.environment_templates.EnvTemplateServices')
@ -45,7 +45,7 @@ class TestCoreServices(base.MuranoTestCase):
template_services_mock.get_description.return_value = \ template_services_mock.get_description.return_value = \
fixture_env_apps.env_template_desc fixture_env_apps.env_template_desc
template_des = self.core_services.get_template_data('any', '/services') template_des = self.core_services.get_template_data('any', '/services')
self.assertEqual(template_des, fixture_apps.applications_desc) self.assertEqual(fixture_apps.applications_desc, template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')
@mock.patch('murano.db.services.environment_templates.EnvTemplateServices') @mock.patch('murano.db.services.environment_templates.EnvTemplateServices')
@ -58,7 +58,7 @@ class TestCoreServices(base.MuranoTestCase):
template_des = \ template_des = \
self.core_services.get_template_data('any', self.core_services.get_template_data('any',
'/services/tomcat_id') '/services/tomcat_id')
self.assertEqual(template_des, fixture2.application_tomcat_desc) self.assertEqual(fixture2.application_tomcat_desc, template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')
@mock.patch('murano.db.services.environment_templates.EnvTemplateServices') @mock.patch('murano.db.services.environment_templates.EnvTemplateServices')
@ -72,7 +72,7 @@ class TestCoreServices(base.MuranoTestCase):
post_env_template_data('any', post_env_template_data('any',
fixture2.env_template_desc, fixture2.env_template_desc,
'/services') '/services')
self.assertEqual(template_des, fixture2.env_template_desc) self.assertEqual(fixture2.env_template_desc, template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')
@mock.patch('murano.db.services.environment_templates.EnvTemplateServices') @mock.patch('murano.db.services.environment_templates.EnvTemplateServices')
@ -86,7 +86,7 @@ class TestCoreServices(base.MuranoTestCase):
delete_env_template_data('any', delete_env_template_data('any',
'/services/54aaa43d-5970') '/services/54aaa43d-5970')
template_des = self.core_services.get_template_data('any', '/services') template_des = self.core_services.get_template_data('any', '/services')
self.assertEqual(template_des, [fixture.application_tomcat_desc]) self.assertEqual([fixture.application_tomcat_desc], template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')
@mock.patch('murano.db.services.environment_templates.EnvTemplateServices') @mock.patch('murano.db.services.environment_templates.EnvTemplateServices')
@ -120,5 +120,5 @@ class TestCoreServices(base.MuranoTestCase):
'/services') '/services')
template_des = \ template_des = \
self.core_services.get_template_data('any', '/services') self.core_services.get_template_data('any', '/services')
self.assertEqual(template_des, fservices.applications_desc) self.assertEqual(fservices.applications_desc, template_des)
template_services_mock.get_description.assert_called_with('any') template_services_mock.get_description.assert_called_with('any')

View File

@ -62,4 +62,4 @@ class TestEnvironmentServices(base.MuranoWithDBTestCase):
environment.id environment.id
) )
self.assertEqual(actual_status, expected_status) self.assertEqual(expected_status, actual_status)

View File

@ -39,8 +39,8 @@ class TestTemplateServices(base.MuranoWithDBTestCase,
"name": "my_template" "name": "my_template"
} }
template_des = self.template_services.create(body, 'tenant_id') template_des = self.template_services.create(body, 'tenant_id')
self.assertEqual(template_des.description, self.assertEqual(fixture.environment_template_desc,
fixture.environment_template_desc) template_des.description)
def test_get_empty_template(self): def test_get_empty_template(self):
"""Check obtaining information about a template without services.""" """Check obtaining information about a template without services."""
@ -48,17 +48,17 @@ class TestTemplateServices(base.MuranoWithDBTestCase,
self.test_create_template() self.test_create_template()
template = \ template = \
self.template_services.get_description("template_id") self.template_services.get_description("template_id")
self.assertEqual(template, fixture.environment_template_desc) self.assertEqual(fixture.environment_template_desc, template)
def test_get_template_services(self): def test_get_template_services(self):
"""Check obtaining information about a template with services.""" """Check obtaining information about a template with services."""
fixture = self.useFixture(et.AppEnvTemplateFixture()) fixture = self.useFixture(et.AppEnvTemplateFixture())
template = self.template_services.create(fixture.env_template_desc, template = self.template_services.create(fixture.env_template_desc,
'tenant_id') 'tenant_id')
self.assertEqual(template.description, fixture.env_template_desc) self.assertEqual(fixture.env_template_desc, template.description)
template_des = \ template_des = \
self.template_services.get_description("template_id") self.template_services.get_description("template_id")
self.assertEqual(template_des, fixture.env_template_desc) self.assertEqual(fixture.env_template_desc, template_des)
def test_get_template_no_exists(self): def test_get_template_no_exists(self):
"""Check obtaining information about a template which """Check obtaining information about a template which

View File

@ -80,7 +80,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
[pkg_created, pkg_name, pkg_fqn]): [pkg_created, pkg_name, pkg_fqn]):
res = api.package_search( res = api.package_search(
{'order_by': [order]}, self.context, limit=10) {'order_by': [order]}, self.context, limit=10)
self.assertEqual(len(res), 10) self.assertEqual(10, len(res))
self.assertEqual(pkg_ids, [r.id for r in res]) self.assertEqual(pkg_ids, [r.id for r in res])
def test_order_by_compound(self): def test_order_by_compound(self):
@ -104,7 +104,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'order_by': ['name', 'created']}, self.context, limit=10) {'order_by': ['name', 'created']}, self.context, limit=10)
self.assertEqual(len(res), 10) self.assertEqual(10, len(res))
self.assertEqual(pkg_a_id + pkg_z_id, [r.id for r in res]) self.assertEqual(pkg_a_id + pkg_z_id, [r.id for r in res])
def test_pagination_backwards(self): def test_pagination_backwards(self):
@ -122,14 +122,14 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)] pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]
res = api.package_search({}, self.context, limit=10) res = api.package_search({}, self.context, limit=10)
self.assertEqual(len(res), 10) self.assertEqual(10, len(res))
self.assertEqual(pkg_ids, [r.id for r in res]) self.assertEqual(pkg_ids, [r.id for r in res])
marker = res[-1].id marker = res[-1].id
res = api.package_search( res = api.package_search(
{'marker': marker, {'marker': marker,
'sort_dir': 'desc'}, self.context, limit=5) 'sort_dir': 'desc'}, self.context, limit=5)
self.assertEqual(len(res), 5) self.assertEqual(5, len(res))
self.assertEqual(list(reversed(pkg_ids[4:9])), self.assertEqual(list(reversed(pkg_ids[4:9])),
[r.id for r in res]) [r.id for r in res])
marker = res[-1].id marker = res[-1].id
@ -137,7 +137,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'marker': marker, {'marker': marker,
'sort_dir': 'desc'}, self.context, limit=5) 'sort_dir': 'desc'}, self.context, limit=5)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
self.assertEqual(list(reversed(pkg_ids[0:4])), self.assertEqual(list(reversed(pkg_ids[0:4])),
[r.id for r in res]) [r.id for r in res])
marker = res[-1].id marker = res[-1].id
@ -145,7 +145,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'marker': marker, {'marker': marker,
'sort_dir': 'desc'}, self.context, limit=5) 'sort_dir': 'desc'}, self.context, limit=5)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
def test_pagination(self): def test_pagination(self):
"""Creates 10 packages with unique names and iterates through them, """Creates 10 packages with unique names and iterates through them,
@ -163,22 +163,22 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)] pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]
res = api.package_search({}, self.context, limit=4) res = api.package_search({}, self.context, limit=4)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
self.assertEqual(pkg_ids[0:4], [r.id for r in res]) self.assertEqual(pkg_ids[0:4], [r.id for r in res])
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
self.assertEqual(pkg_ids[4:8], [r.id for r in res]) self.assertEqual(pkg_ids[4:8], [r.id for r in res])
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
self.assertEqual(pkg_ids[8:10], [r.id for r in res]) self.assertEqual(pkg_ids[8:10], [r.id for r in res])
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
def test_pagination_loops_through_names(self): def test_pagination_loops_through_names(self):
"""Creates 10 packages with the same display name and iterates through them, """Creates 10 packages with the same display name and iterates through them,
@ -191,19 +191,19 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
fully_qualified_name=str(uuid.uuid4())), fully_qualified_name=str(uuid.uuid4())),
self.tenant_id) self.tenant_id)
res = api.package_search({}, self.context, limit=4) res = api.package_search({}, self.context, limit=4)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
marker = res[-1].id marker = res[-1].id
res = api.package_search({'marker': marker}, self.context, limit=4) res = api.package_search({'marker': marker}, self.context, limit=4)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
def test_package_search_search(self): def test_package_search_search(self):
pkg1 = api.package_upload( pkg1 = api.package_upload(
@ -216,20 +216,20 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'search': 'tag1'}, self.context) {'search': 'tag1'}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'search': pkg1.fully_qualified_name}, self.context) {'search': pkg1.fully_qualified_name}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'search': pkg2.fully_qualified_name}, self.context) {'search': pkg2.fully_qualified_name}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'search': 'not_a_valid_uuid'}, self.context) {'search': 'not_a_valid_uuid'}, self.context)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
res = api.package_search( res = api.package_search(
{'search': 'some text'}, self.context) {'search': 'some text'}, self.context)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
def test_package_search_tags(self): def test_package_search_tags(self):
api.package_upload( api.package_upload(
@ -242,13 +242,13 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'tag': ['tag1']}, self.context) {'tag': ['tag1']}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'tag': ['tag2']}, self.context) {'tag': ['tag2']}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'tag': ['tag3']}, self.context) {'tag': ['tag3']}, self.context)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
def test_package_search_type(self): def test_package_search_type(self):
api.package_upload( api.package_upload(
@ -262,10 +262,10 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'type': 'Library'}, self.context) {'type': 'Library'}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'type': 'Application'}, self.context) {'type': 'Application'}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
def test_package_search_disabled(self): def test_package_search_disabled(self):
api.package_upload( api.package_upload(
@ -281,10 +281,10 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
res = api.package_search( res = api.package_search(
{'include_disabled': 'false'}, self.context) {'include_disabled': 'false'}, self.context)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search( res = api.package_search(
{'include_disabled': 'true'}, self.context) {'include_disabled': 'true'}, self.context)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
def test_package_search_owned(self): def test_package_search_owned(self):
api.package_upload( api.package_upload(
@ -297,13 +297,13 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2) fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)
res = api.package_search({'owned': 'true'}, self.context_admin) res = api.package_search({'owned': 'true'}, self.context_admin)
self.assertEqual(len(res), 1) self.assertEqual(1, len(res))
res = api.package_search({'owned': 'false'}, self.context_admin) res = api.package_search({'owned': 'false'}, self.context_admin)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
def test_package_search_no_filters_catalog(self): def test_package_search_no_filters_catalog(self):
res = api.package_search({}, self.context, catalog=True) res = api.package_search({}, self.context, catalog=True)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
api.package_upload( api.package_upload(
self._stub_package( self._stub_package(
@ -325,14 +325,14 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
# catalog=True should show public + mine # catalog=True should show public + mine
res = api.package_search({}, self.context, catalog=True) res = api.package_search({}, self.context, catalog=True)
self.assertEqual(len(res), 3) self.assertEqual(3, len(res))
res = api.package_search({}, self.context_admin, catalog=True) res = api.package_search({}, self.context_admin, catalog=True)
self.assertEqual(len(res), 3) self.assertEqual(3, len(res))
def test_package_search_no_filters(self): def test_package_search_no_filters(self):
res = api.package_search({}, self.context) res = api.package_search({}, self.context)
self.assertEqual(len(res), 0) self.assertEqual(0, len(res))
api.package_upload( api.package_upload(
self._stub_package( self._stub_package(
@ -354,13 +354,13 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
# I can only edit mine pkgs # I can only edit mine pkgs
res = api.package_search({}, self.context) res = api.package_search({}, self.context)
self.assertEqual(len(res), 2) self.assertEqual(2, len(res))
for pkg in res: for pkg in res:
self.assertEqual(pkg.owner_id, self.tenant_id) self.assertEqual(self.tenant_id, pkg.owner_id)
# Admin can see everything # Admin can see everything
res = api.package_search({}, self.context_admin) res = api.package_search({}, self.context_admin)
self.assertEqual(len(res), 4) self.assertEqual(4, len(res))
def test_list_empty_categories(self): def test_list_empty_categories(self):
res = api.category_get_names() res = api.category_get_names()

View File

@ -37,12 +37,12 @@ class TestContracts(test_case.DslTestCase):
def test_string_contract(self): def test_string_contract(self):
result = self._runner.testStringContract('qwerty') result = self._runner.testStringContract('qwerty')
self.assertIsInstance(result, types.StringTypes) self.assertIsInstance(result, types.StringTypes)
self.assertEqual(result, 'qwerty') self.assertEqual('qwerty', result)
def test_string_from_number_contract(self): def test_string_from_number_contract(self):
result = self._runner.testStringContract(123) result = self._runner.testStringContract(123)
self.assertIsInstance(result, types.StringTypes) self.assertIsInstance(result, types.StringTypes)
self.assertEqual(result, '123') self.assertEqual('123', result)
def test_string_null_contract(self): def test_string_null_contract(self):
self.assertIsNone(self._runner.testStringContract(None)) self.assertIsNone(self._runner.testStringContract(None))
@ -50,12 +50,12 @@ class TestContracts(test_case.DslTestCase):
def test_int_contract(self): def test_int_contract(self):
result = self._runner.testIntContract(123) result = self._runner.testIntContract(123)
self.assertIsInstance(result, int) self.assertIsInstance(result, int)
self.assertEqual(result, 123) self.assertEqual(123, result)
def test_int_from_string_contract(self): def test_int_from_string_contract(self):
result = self._runner.testIntContract('456') result = self._runner.testIntContract('456')
self.assertIsInstance(result, int) self.assertIsInstance(result, int)
self.assertEqual(result, 456) self.assertEqual(456, result)
def test_int_from_string_contract_failure(self): def test_int_from_string_contract_failure(self):
self.assertRaises(exceptions.ContractViolationException, self.assertRaises(exceptions.ContractViolationException,
@ -102,7 +102,7 @@ class TestContracts(test_case.DslTestCase):
def test_class_contract_by_ref(self): def test_class_contract_by_ref(self):
arg = om.Object('SampleClass2', class2Property='qwerty') arg = om.Object('SampleClass2', class2Property='qwerty')
result = self._runner.testClassContract(arg) result = self._runner.testClassContract(arg)
self.assertEqual(result.id, arg.id) self.assertEqual(arg.id, result.id)
def test_class_contract_failure(self): def test_class_contract_failure(self):
self.assertRaises( self.assertRaises(
@ -124,7 +124,7 @@ class TestContracts(test_case.DslTestCase):
object_id = self._runner.root.get_property('sampleClass').object_id object_id = self._runner.root.get_property('sampleClass').object_id
result = self._runner.testClassFromIdContract(object_id) result = self._runner.testClassFromIdContract(object_id)
self.assertIsInstance(result, dsl.MuranoObjectInterface) self.assertIsInstance(result, dsl.MuranoObjectInterface)
self.assertEqual(result.id, object_id) self.assertEqual(object_id, result.id)
def test_check_contract(self): def test_check_contract(self):
arg = om.Object('SampleClass2', class2Property='qwerty') arg = om.Object('SampleClass2', class2Property='qwerty')

View File

@ -36,13 +36,13 @@ class TestExecution(test_case.DslTestCase):
def test_trace(self): def test_trace(self):
runner = self._load() runner = self._load()
self.assertEqual(self.traces, []) self.assertEqual([], self.traces)
runner.testTrace(123) runner.testTrace(123)
self.assertEqual(self.traces, [123, 'STRING', 'ANOTHER_STRING']) self.assertEqual([123, 'STRING', 'ANOTHER_STRING'], self.traces)
runner.testTrace(321) runner.testTrace(321)
self.assertEqual(self.traces, [ self.assertEqual([123, 'STRING', 'ANOTHER_STRING',
123, 'STRING', 'ANOTHER_STRING', 321, 'STRING', 'ANOTHER_STRING'],
321, 'STRING', 'ANOTHER_STRING']) self.traces)
def test_exception(self): def test_exception(self):
class CustomException(Exception): class CustomException(Exception):

View File

@ -62,21 +62,21 @@ class TestExecutionPlan(base.MuranoTestCase):
self._read('application.template'), self._read('application.template'),
Loader=self.yaml_loader) Loader=self.yaml_loader)
template = self.agent.build_execution_plan(template, self.resources) template = self.agent.build_execution_plan(template, self.resources)
self.assertEqual(template, self._get_application()) self.assertEqual(self._get_application(), template)
def test_execution_plan_v2_chef_type(self): def test_execution_plan_v2_chef_type(self):
template = yamllib.load( template = yamllib.load(
self._read('chef.template'), self._read('chef.template'),
Loader=self.yaml_loader) Loader=self.yaml_loader)
template = self.agent.build_execution_plan(template, self.resources) template = self.agent.build_execution_plan(template, self.resources)
self.assertEqual(template, self._get_chef()) self.assertEqual(self._get_chef(), template)
def test_execution_plan_v2_telnet_application(self): def test_execution_plan_v2_telnet_application(self):
template = yamllib.load( template = yamllib.load(
self._read('DeployTelnet.template'), self._read('DeployTelnet.template'),
Loader=self.yaml_loader) Loader=self.yaml_loader)
template = self.agent.build_execution_plan(template, self.resources) template = self.agent.build_execution_plan(template, self.resources)
self.assertEqual(template, self._get_telnet_application()) self.assertEqual(self._get_telnet_application(), template)
def test_execution_plan_v2_tomcat_application(self): def test_execution_plan_v2_tomcat_application(self):
template = yamllib.load( template = yamllib.load(
@ -89,14 +89,14 @@ class TestExecutionPlan(base.MuranoTestCase):
self._read('application_without_files.template'), self._read('application_without_files.template'),
Loader=self.yaml_loader) Loader=self.yaml_loader)
template = self.agent.build_execution_plan(template, self.resources) template = self.agent.build_execution_plan(template, self.resources)
self.assertEqual(template, self._get_app_without_files()) self.assertEqual(self._get_app_without_files(), template)
def test_execution_plan_v2_app_with_file_in_template(self): def test_execution_plan_v2_app_with_file_in_template(self):
template = yamllib.load( template = yamllib.load(
self._read('template_with_files.template'), self._read('template_with_files.template'),
Loader=self.yaml_loader) Loader=self.yaml_loader)
template = self.agent.build_execution_plan(template, self.resources) template = self.agent.build_execution_plan(template, self.resources)
self.assertEqual(template, self._get_app_with_files_in_template()) self.assertEqual(self._get_app_with_files_in_template(), template)
def _get_application(self): def _get_application(self):
return { return {

View File

@ -48,4 +48,4 @@ class TestHotPackage(test_base.MuranoTestCase):
files = murano.packages.hot_package.HotPackage \ files = murano.packages.hot_package.HotPackage \
._translate_files(package_dir) ._translate_files(package_dir)
msg = "heat files were not generated correctly. Expected empty dict" msg = "heat files were not generated correctly. Expected empty dict"
self.assertEqual(files, [], msg) self.assertEqual([], files, msg)

View File

@ -28,19 +28,18 @@ class TestHotV1(test_base.MuranoTestCase):
package = load_utils.load_from_dir(package_dir) package = load_utils.load_from_dir(package_dir)
self.assertNotEqual(package.supplier, None) self.assertNotEqual(package.supplier, None)
self.assertEqual(package.supplier['Name'], 'Supplier Name') self.assertEqual('Supplier Name', package.supplier['Name'])
self.assertEqual(package.supplier['CompanyUrl'], { self.assertEqual({'Link': 'http://example.com',
'Link': 'http://example.com', 'Text': 'Example Company'},
'Text': 'Example Company' package.supplier['CompanyUrl'])
})
self.assertEqual( self.assertEqual(
package.supplier['Summary'], 'Company summary goes here',
'Company summary goes here' package.supplier['Summary']
) )
self.assertEqual( self.assertEqual(
package.supplier['Description'], 'Marked up company description goes here',
'Marked up company description goes here' package.supplier['Description']
) )
self.assertEqual(package.supplier['Logo'], 'test_supplier_logo.png') self.assertEqual('test_supplier_logo.png', package.supplier['Logo'])
self.assertEqual(imghdr.what('', package.supplier_logo), 'png') self.assertEqual('png', imghdr.what('', package.supplier_logo))

View File

@ -26,19 +26,18 @@ class TestMplV1(test_base.MuranoTestCase):
package = load_utils.load_from_dir(package_dir) package = load_utils.load_from_dir(package_dir)
self.assertNotEqual(package.supplier, None) self.assertNotEqual(package.supplier, None)
self.assertEqual(package.supplier['Name'], 'Supplier Name') self.assertEqual('Supplier Name', package.supplier['Name'])
self.assertEqual(package.supplier['CompanyUrl'], { self.assertEqual({'Link': 'http://example.com',
'Link': 'http://example.com', 'Text': 'Example Company'},
'Text': 'Example Company' package.supplier['CompanyUrl'])
})
self.assertEqual( self.assertEqual(
package.supplier['Summary'], 'Company summary goes here',
'Company summary goes here' package.supplier['Summary']
) )
self.assertEqual( self.assertEqual(
package.supplier['Description'], 'Marked up company description goes here',
'Marked up company description goes here' package.supplier['Description']
) )
self.assertEqual(package.supplier['Logo'], 'test_supplier_logo.png') self.assertEqual('test_supplier_logo.png', package.supplier['Logo'])
self.assertEqual(imghdr.what('', package.supplier_logo), 'png') self.assertEqual('png', imghdr.what('', package.supplier_logo))