def test_positive_CRUD_with_attributes(module_org, module_locs): """Check if Environment with attributes can be created, updated and removed :id: d2187971-86b2-40c9-a93c-66f37691ae2b :BZ: 1337947 :expectedresults: 1. Environment is created and has parameters assigned 2. Environment can be listed by parameters 3. Environment can be updated 4. Environment can be removed :CaseImportance: Critical """ # Create with attributes env_name = gen_string('alpha') environment = make_environment( {'location-ids': module_locs[0].id, 'organization-ids': module_org.id, 'name': env_name} ) assert module_locs[0].name in environment['locations'] assert module_org.name in environment['organizations'] assert env_name == environment['name'] # List by name result = Environment.list({'search': f'name={env_name}'}) assert len(result) == 1 assert result[0]['name'] == env_name # List by org loc id results = Environment.list({'organization-id': module_org.id, 'location-id': module_locs[0].id}) assert env_name in [res['name'] for res in results] # List by org loc name results = Environment.list({'organization': module_org.name, 'location': module_locs[0].name}) assert env_name in [res['name'] for res in results] # Update org and loc new_org = entities.Organization().create() Environment.update( { 'location-ids': module_locs[1].id, 'organization-ids': new_org.id, 'name': environment['name'], } ) env_info = Environment.info({'name': environment['name']}) assert module_locs[1].name in env_info['locations'] assert module_locs[0].name not in env_info['locations'] assert new_org.name in env_info['organizations'] assert module_org.name not in env_info['organizations'] # Update name new_env_name = gen_string('alpha') Environment.update({'id': environment['id'], 'new-name': new_env_name}) env_info = Environment.info({'id': environment['id']}) assert env_info['name'] == new_env_name # Delete Environment.delete({'id': environment['id']}) with pytest.raises(CLIReturnCodeError): Environment.info({'id': environment['id']})
def test_positive_delete_by_name(self): """Delete the environment by its name. @id: 48765173-6086-4b91-9da7-594135f68751 @Assert: Environment is deleted. """ environment = make_environment() Environment.delete({'name': environment['name']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'name': environment['name']})
def test_negative_delete_by_id(self): """Create Environment then delete it by wrong ID @id: fe77920c-62fd-4e0e-b960-a940a1370d10 @assert: Environment is not deleted """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): Environment.delete({'id': entity_id})
def test_negative_delete_by_id(self): """Create Environment then delete it by wrong ID @feature: Environment @assert: Environment is not deleted """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): Environment.delete({'id': entity_id})
def test_positive_delete_by_name(self): """Delete the environment by its name. @Feature: Environment @Assert: Environment is deleted. """ environment = make_environment() Environment.delete({'name': environment['name']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'name': environment['name']})
def test_negative_delete_by_id(self): """Create Environment then delete it by wrong ID :id: fe77920c-62fd-4e0e-b960-a940a1370d10 :expectedresults: Environment is not deleted :CaseImportance: Medium """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): Environment.delete({'id': entity_id})
def test_negative_delete_by_id(entity_id): """Create Environment then delete it by wrong ID :id: fe77920c-62fd-4e0e-b960-a940a1370d10 :parametrized: yes :expectedresults: Environment is not deleted :CaseImportance: Medium """ with pytest.raises(CLIReturnCodeError): Environment.delete({'id': entity_id})
def test_positive_delete_by_name(self): """Delete the environment by its name. :id: 48765173-6086-4b91-9da7-594135f68751 :expectedresults: Environment is deleted. :CaseImportance: Critical """ environment = make_environment() Environment.delete({'name': environment['name']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'name': environment['name']})
def test_negative_delete_by_id(self): """Create Environment then delete it by wrong ID :id: fe77920c-62fd-4e0e-b960-a940a1370d10 :expectedresults: Environment is not deleted :CaseImportance: Critical """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): Environment.delete({'id': entity_id})
def test_positive_delete_by_id(self): """Create Environment with valid values then delete it by ID @feature: Environment @assert: Environment is deleted """ for name in valid_environments_list(): with self.subTest(name): environment = make_environment({'name': name}) Environment.delete({'id': environment['id']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'id': environment['id']})
def test_positive_delete_by_id(self): """Create Environment with valid values then delete it by ID :id: e25af73a-d4ef-4287-83bf-625337d91392 :expectedresults: Environment is deleted :CaseImportance: Critical """ for name in valid_environments_list(): with self.subTest(name): environment = make_environment({'name': name}) Environment.delete({'id': environment['id']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'id': environment['id']})
def test_positive_CRUD_with_attributes(self): """Check if Environment with attributes can be created, updated and removed :id: d2187971-86b2-40c9-a93c-66f37691ae2b :bz: 1337947 :expectedresults: 1. Environment is created and has parameters assigned 2. Environment can be listed by parameters 3. Environment can be updated 4. Environment can be removed :CaseImportance: Critical """ # Create with attributes env_name = gen_string('alpha') environment = make_environment({ 'location-ids': self.loc.id, 'organization-ids': self.org.id, 'name': env_name, }) self.assertIn(self.loc.name, environment['locations']) self.assertIn(self.org.name, environment['organizations']) self.assertEqual(env_name, environment['name']) # List by name result = Environment.list({'search': 'name={0}'.format(env_name)}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], env_name) # List by org loc id results = Environment.list({ 'organization-id': self.org.id, 'location-id': self.loc.id, }) self.assertIn(env_name, [res['name'] for res in results]) # List by org loc name results = Environment.list({ 'organization': self.org.name, 'location': self.loc.name, }) self.assertIn(env_name, [res['name'] for res in results]) # Update org and loc new_org = entities.Organization().create() Environment.update({ 'location-ids': self.loc2.id, 'organization-ids': new_org.id, 'name': environment['name'], }) env_info = Environment.info({'name': environment['name']}) self.assertIn(self.loc2.name, env_info['locations']) self.assertNotIn(self.loc.name, env_info['locations']) self.assertIn(new_org.name, env_info['organizations']) self.assertNotIn(self.org.name, env_info['organizations']) # Update name new_env_name = gen_string('alpha') Environment.update({ 'id': environment['id'], 'new-name': new_env_name, }) env_info = Environment.info({'id': environment['id']}) self.assertEqual(env_info['name'], new_env_name) # Delete Environment.delete({'id': environment['id']}) with self.assertRaises(CLIReturnCodeError): Environment.info({'id': environment['id']})
def _cleanup(): if Environment.exists(search=('name', environment['name'])): Environment.delete(options={'id': environment['id']})