Merge "Use assertIn, assertNotIn and assertIsNotNone"

This commit is contained in:
Jenkins 2016-08-08 16:15:18 +00:00 committed by Gerrit Code Review
commit 8b0b1d5497
5 changed files with 42 additions and 42 deletions

View File

@ -380,7 +380,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
self.assertEqual(2, len(res))
for cat in res:
self.assertTrue(cat.id is not None)
self.assertIsNotNone(cat.id)
self.assertTrue(cat.name.startswith('cat'))
def test_package_upload(self):

View File

@ -27,7 +27,7 @@ class TestHotV1(test_base.MuranoTestCase):
)
package = load_utils.load_from_dir(package_dir)
self.assertNotEqual(package.supplier, None)
self.assertIsNotNone(package.supplier)
self.assertEqual('Supplier Name', package.supplier['Name'])
self.assertEqual({'Link': 'http://example.com',
'Text': 'Example Company'},

View File

@ -25,7 +25,7 @@ class TestMplV1(test_base.MuranoTestCase):
)
package = load_utils.load_from_dir(package_dir)
self.assertNotEqual(package.supplier, None)
self.assertIsNotNone(package.supplier)
self.assertEqual('Supplier Name', package.supplier['Name'])
self.assertEqual({'Link': 'http://example.com',
'Text': 'Example Company'},

View File

@ -111,8 +111,8 @@ class TestCongressRules(unittest.TestCase):
def test_transitive_closure(self):
closure = congress.CongressRulesManager.transitive_closure(
[(1, 2), (2, 3), (3, 4)])
self.assertTrue((1, 4) in closure)
self.assertTrue((2, 4) in closure)
self.assertIn((1, 4), closure)
self.assertIn((2, 4), closure)
def test_empty_model(self):
congress_rules = congress.CongressRulesManager()
@ -122,49 +122,49 @@ class TestCongressRules(unittest.TestCase):
def test_convert_simple_app(self):
rules_str = self._create_and_check_rules_str('model')
self.assertFalse("instance." in rules_str)
self.assertNotIn("instance.", rules_str)
def test_convert_model_two_instances(self):
rules_str = self._create_and_check_rules_str('model_two_instances')
self.assertFalse("\"instances\"" in rules_str)
self.assertNotIn("\"instances\"", rules_str)
def test_convert_model_with_relations(self):
rules_str = self._create_rules_str('model_with_relations.yaml')
self.assertFalse(
self.assertNotIn(
'murano:properties+("50fa68ff-cd9a-4845-b573-2c80879d158d", '
'"server", "8ce94f23-f16a-40a1-9d9d-a877266c315d")' in rules_str)
'"server", "8ce94f23-f16a-40a1-9d9d-a877266c315d")', rules_str)
self.assertTrue(
self.assertIn(
'murano:relationships+("50fa68ff-cd9a-4845-b573-2c80879d158d", '
'"8ce94f23-f16a-40a1-9d9d-a877266c315d", "server")' in rules_str)
'"8ce94f23-f16a-40a1-9d9d-a877266c315d", "server")', rules_str)
self.assertTrue(
self.assertIn(
'murano:relationships+("0aafd67e-72e9-4ae0-bb62-fe724f77df2a", '
'"ed8df2b0-ddd2-4009-b3c9-2e7a368f3cb8", "instance")' in rules_str)
'"ed8df2b0-ddd2-4009-b3c9-2e7a368f3cb8", "instance")', rules_str)
def test_convert_model_transitive_relationships(self):
rules_str = self._create_rules_str('model_with_relations.yaml')
self.assertTrue(
self.assertIn(
'murano:connected+("50fa68ff-cd9a-4845-b573-2c80879d158d", '
'"8ce94f23-f16a-40a1-9d9d-a877266c315d")' in rules_str)
'"8ce94f23-f16a-40a1-9d9d-a877266c315d")', rules_str)
self.assertTrue(
self.assertIn(
'murano:connected+("8ce94f23-f16a-40a1-9d9d-a877266c315d", '
'"fc6b8c41-166f-4fc9-a640-d82009e0a03d")' in rules_str)
'"fc6b8c41-166f-4fc9-a640-d82009e0a03d")', rules_str)
def test_convert_model_services_relationship(self):
rules_str = self._create_rules_str('model_with_relations.yaml')
self.assertTrue(
self.assertIn(
'murano:relationships+("3409bdd0590e4c60b70fda5e6777ff96", '
'"8ce94f23-f16a-40a1-9d9d-a877266c315d", "services")' in rules_str)
'"8ce94f23-f16a-40a1-9d9d-a877266c315d", "services")', rules_str)
self.assertTrue(
self.assertIn(
'murano:relationships+("3409bdd0590e4c60b70fda5e6777ff96", '
'"50fa68ff-cd9a-4845-b573-2c80879d158d", "services")' in rules_str)
'"50fa68ff-cd9a-4845-b573-2c80879d158d", "services")', rules_str)
def test_convert_model_complex(self):
self._create_and_check_rules_str('model_complex')
@ -189,21 +189,21 @@ class TestCongressRules(unittest.TestCase):
rules_str = self._create_rules_str('model.yaml', package_loader)
self.assertTrue(
self.assertIn(
'murano:parent_types+("0c810278-7282-4e4a-9d69-7b4c36b6ce6f",'
' "parent1")' in rules_str)
' "parent1")', rules_str)
self.assertTrue(
self.assertIn(
'murano:parent_types+("0c810278-7282-4e4a-9d69-7b4c36b6ce6f",'
' "parent2")' in rules_str)
' "parent2")', rules_str)
self.assertTrue(
self.assertIn(
'murano:parent_types+("0c810278-7282-4e4a-9d69-7b4c36b6ce6f",'
' "grand-parent")' in rules_str)
' "grand-parent")', rules_str)
self.assertTrue(
self.assertIn(
'murano:parent_types+("0c810278-7282-4e4a-9d69-7b4c36b6ce6f",'
' "io.murano.apps.linux.Git")' in rules_str)
' "io.murano.apps.linux.Git")', rules_str)
def test_to_dictionary(self):
"""test to_dictionary
@ -235,18 +235,18 @@ class TestCongressRules(unittest.TestCase):
rules = congress_rules.convert(model, tenant_id=tenant_id)
rules_str = ", \n".join(map(str, rules))
self.assertTrue('murano:objects+("1", "{0}", "t1")'.format(tenant_id)
in rules_str)
self.assertTrue('murano:objects+("2", "1", "t2")' in rules_str)
self.assertTrue('murano:objects+("3", "2", "t3")' in rules_str)
self.assertIn('murano:objects+("1", "{0}", "t1")'.format(tenant_id),
rules_str)
self.assertIn('murano:objects+("2", "1", "t2")', rules_str)
self.assertIn('murano:objects+("3", "2", "t3")', rules_str)
def test_environment_owner(self):
model = self._load_file("model.yaml")
congress_rules = congress.CongressRulesManager()
rules = congress_rules.convert(model, tenant_id='tenant1')
rules_str = ", \n".join(map(str, rules))
self.assertTrue('murano:objects+("c86104748a0c4907b4c5981e6d3bce9f", '
'"tenant1", "io.murano.Environment")' in rules_str)
self.assertIn('murano:objects+("c86104748a0c4907b4c5981e6d3bce9f", '
'"tenant1", "io.murano.Environment")', rules_str)
def test_wordpress(self):
package_loader = MockPackageLoader([
@ -295,6 +295,6 @@ class TestCongressRules(unittest.TestCase):
def test_state_rule(self):
rules_str = self._create_rules_str('model.yaml')
self.assertTrue(
'murano:states+("c86104748a0c4907b4c5981e6d3bce9f", "pending")'
in rules_str)
self.assertIn(
'murano:states+("c86104748a0c4907b4c5981e6d3bce9f", "pending")',
rules_str)

View File

@ -111,10 +111,10 @@ class TestModelPolicyEnforcer(base.MuranoTestCase):
result = enforcer._parse_simulation_result(
'predeploy_errors', 'env1', congress_response)
self.assertFalse("unexpected response" in result)
self.assertTrue("Instance 1 has problem" in result)
self.assertTrue("Instance 2 has problem" in result)
self.assertFalse("Instance 3 has problem" in result)
self.assertNotIn("unexpected response", result)
self.assertIn("Instance 1 has problem", result)
self.assertIn("Instance 2 has problem", result)
self.assertNotIn("Instance 3 has problem", result)
def test_none_model(self):
executor = engine.TaskExecutor(self.task)