def test_positive_update_content_source(self): """Update hostgroup's content source :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual( hostgroup['content-source']['name'], new_content_source['name'])
def test_negative_update_content_source(self): """Attempt to update hostgroup's content source with invalid value :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26 :BZ: 1260697, 1313056 :expectedresults: Host group was not updated. Content source remains the same as it was before update :CaseImportance: Medium """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) with self.assertRaises(CLIBaseError): HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999), }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual( hostgroup['content-source']['name'], content_source['name'])
def test_positive_update_content_source(self): """Update hostgroup's content source :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['content-source']['name'], new_content_source['name'])
def test_negative_update_content_source(self): """Attempt to update hostgroup's content source with invalid value :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26 :BZ: 1260697, 1313056 :expectedresults: Host group was not updated. Content source remains the same as it was before update :CaseImportance: Medium """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999), }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['content-source']['name'], content_source['name'])
def test_positive_update_hostgroup( request, module_puppet_org, env, puppet_content_source, puppet_classes, session_puppet_enabled_sat, puppet_proxy_port_range, ): """Update hostgroup's content source, name and puppet classes :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source, name and puppet classes :CaseLevel: Integration """ with session_puppet_enabled_sat: hostgroup = make_hostgroup({ 'content-source-id': puppet_content_source['id'], 'organization-ids': module_puppet_org.id, 'environment-id': env.id, 'query-organization-id': module_puppet_org.id, }) new_content_source = make_proxy() @request.addfinalizer def _cleanup(): with session_puppet_enabled_sat: HostGroup.delete({'id': hostgroup['id']}) capsule_cleanup(new_content_source['id']) assert len(hostgroup['puppetclasses']) == 0 new_name = valid_hostgroups_list()[0] puppet_class_names = [puppet['name'] for puppet in puppet_classes] HostGroup.update({ 'new-name': new_name, 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], 'puppet-classes': puppet_class_names, }) hostgroup = HostGroup.info({'id': hostgroup['id']}) assert hostgroup['name'] == new_name assert hostgroup['content-source']['name'] == new_content_source[ 'name'] for puppet_class_name in puppet_class_names: assert puppet_class_name in hostgroup['puppetclasses']
def test_negative_create_with_name(self): """Don't create an HostGroup with invalid data. @id: 853a6d43-129a-497b-94f0-08dc622862f8 @Assert: HostGroup is not created. """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): HostGroup.create({'name': name})
def test_positive_impact_delete_attribute(self): """Impact on variable after deleting associated attribute. :id: ac6f3a65-ed39-4e97-bdee-349f08bd878e :steps: 1. Create a variable with matcher for some attribute. 2. Delete the attribute. 3. Recreate the attribute with same name as earlier. :expectedresults: 1. The matcher for deleted attribute removed from variable. 2. On recreating attribute, the matcher should not reappear in variable. :CaseLevel: Integration """ hostgroup_name = gen_string('alpha') matcher_value = gen_string('alpha') smart_variable = make_smart_variable( {'puppet-class': self.puppet_class['name']}) hostgroup = make_hostgroup({ 'name': hostgroup_name, 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) SmartVariable.add_override_value({ 'smart-variable-id': smart_variable['id'], 'match': 'hostgroup={0}'.format(hostgroup_name), 'value': matcher_value, }) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual( smart_variable['override-values']['values']['1']['match'], 'hostgroup={0}'.format(hostgroup_name)) self.assertEqual( smart_variable['override-values']['values']['1']['value'], matcher_value, ) HostGroup.delete({'id': hostgroup['id']}) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual(len(smart_variable['override-values']['values']), 0) make_hostgroup({ 'name': hostgroup_name, 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual(len(smart_variable['override-values']['values']), 0)
def test_negative_delete_by_id(self): """Create HostGroup then delete it by wrong ID @id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3 @assert: HostGroup is not deleted """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): HostGroup.delete({'id': entity_id})
def test_negative_create_with_name(self): """Don't create an HostGroup with invalid data. :id: 853a6d43-129a-497b-94f0-08dc622862f8 :expectedresults: HostGroup is not created. """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): HostGroup.create({'name': name})
def test_negative_create_with_name(self): """Don't create an HostGroup with invalid data. @Feature: HostGroup @Assert: HostGroup is not created. """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): HostGroup.create({'name': name})
def test_negative_create_with_name(name): """Don't create an HostGroup with invalid data. :id: 853a6d43-129a-497b-94f0-08dc622862f8 :parametrized: yes :expectedresults: HostGroup is not created. """ with pytest.raises(CLIReturnCodeError): HostGroup.create({'name': name})
def test_negative_delete_by_id(self): """Create HostGroup then delete it by wrong ID @feature: HostGroup @assert: HostGroup is not deleted """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): HostGroup.delete({'id': entity_id})
def test_negative_update_name(hostgroup): """Create HostGroup then fail to update its name :id: 42d208a4-f518-4ff2-9b7a-311adb460abd :expectedresults: HostGroup name is not updated """ new_name = invalid_values_list()[0] with pytest.raises(CLIReturnCodeError): HostGroup.update({'id': hostgroup['id'], 'new-name': new_name}) result = HostGroup.info({'id': hostgroup['id']}) assert hostgroup['name'] == result['name']
def test_negative_delete_by_id(self): """Create HostGroup then delete it by wrong ID :id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3 :expectedresults: HostGroup is not deleted :CaseLevel: Integration """ entity_id = invalid_id_list()[0] with self.assertRaises(CLIReturnCodeError): HostGroup.delete({'id': entity_id})
def test_positive_impact_delete_attribute(self): """Impact on variable after deleting associated attribute. @id: ac6f3a65-ed39-4e97-bdee-349f08bd878e @steps: 1. Create a variable with matcher for some attribute. 2. Delete the attribute. 3. Recreate the attribute with same name as earlier. @assert: 1. The matcher for deleted attribute removed from variable. 2. On recreating attribute, the matcher should not reappear in variable. @CaseLevel: Integration """ hostgroup_name = gen_string('alpha') matcher_value = gen_string('alpha') smart_variable = make_smart_variable( {'puppet-class': self.puppet_class['name']}) hostgroup = make_hostgroup({ 'name': hostgroup_name, 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) SmartVariable.add_override_value({ 'smart-variable-id': smart_variable['id'], 'match': 'hostgroup={0}'.format(hostgroup_name), 'value': matcher_value, }) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual( smart_variable['override-values']['values']['1']['match'], 'hostgroup={0}'.format(hostgroup_name) ) self.assertEqual( smart_variable['override-values']['values']['1']['value'], matcher_value, ) HostGroup.delete({'id': hostgroup['id']}) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual(len(smart_variable['override-values']['values']), 0) make_hostgroup({ 'name': hostgroup_name, 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) smart_variable = SmartVariable.info({'id': smart_variable['id']}) self.assertEqual(len(smart_variable['override-values']['values']), 0)
def test_negative_delete_by_id(self): """Create HostGroup then delete it by wrong ID :id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3 :expectedresults: HostGroup is not deleted :CaseImportance: Critical """ for entity_id in invalid_id_list(): with self.subTest(entity_id): with self.assertRaises(CLIReturnCodeError): HostGroup.delete({'id': entity_id})
def test_negative_create_with_name(self): """Don't create an HostGroup with invalid data. :id: 853a6d43-129a-497b-94f0-08dc622862f8 :expectedresults: HostGroup is not created. :CaseImportance: Critical """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): HostGroup.create({'name': name})
def test_positive_update_name(self): """@Test: Successfully update an HostGroup. @Feature: HostGroup @Assert: HostGroup is updated. """ hostgroup = make_hostgroup() for new_name in valid_data_list(): with self.subTest(new_name): HostGroup.update({"id": hostgroup["id"], "new-name": new_name}) hostgroup = HostGroup.info({"id": hostgroup["id"]}) self.assertEqual(hostgroup["name"], new_name)
def test_positive_delete_by_id(self): """Create HostGroup with valid values then delete it by ID @feature: HostGroup @assert: HostGroup is deleted """ for name in valid_hostgroups_list(): with self.subTest(name): hostgroup = make_hostgroup({'name': name}) HostGroup.delete({'id': hostgroup['id']}) with self.assertRaises(CLIReturnCodeError): HostGroup.info({'id': hostgroup['id']})
def test_positive_delete_by_id(self): """Create HostGroup with valid values then delete it by ID @id: fe7dedd4-d7c3-4c70-b70d-c2deff357b76 @assert: HostGroup is deleted """ for name in valid_hostgroups_list(): with self.subTest(name): hostgroup = make_hostgroup({'name': name}) HostGroup.delete({'id': hostgroup['id']}) with self.assertRaises(CLIReturnCodeError): HostGroup.info({'id': hostgroup['id']})
def test_negative_update(self): """@test: Create HostGroup then fail to update its name @feature: HostGroup @assert: HostGroup name is not updated """ hostgroup = make_hostgroup() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): HostGroup.update({"id": hostgroup["id"], "new-name": new_name}) result = HostGroup.info({"id": hostgroup["id"]}) self.assertEqual(hostgroup["name"], result["name"])
def test_positive_delete(self): """@test: Create HostGroup with valid values then delete it by ID @feature: HostGroup @assert: HostGroup is deleted """ for name in valid_data_list(): with self.subTest(name): hostgroup = make_hostgroup({"name": name}) HostGroup.delete({"id": hostgroup["id"]}) with self.assertRaises(CLIReturnCodeError): HostGroup.info({"id": hostgroup["id"]})
def test_positive_update_name(self): """Successfully update an HostGroup. @Feature: HostGroup @Assert: HostGroup is updated. """ hostgroup = make_hostgroup() for new_name in valid_hostgroups_list(): with self.subTest(new_name): HostGroup.update({ 'id': hostgroup['id'], 'new-name': new_name, }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], new_name)
def test_positive_update_name(self): """Successfully update an HostGroup. @id: a36e3cbe-83d9-44ce-b8f7-5fab2a2cadf9 @Assert: HostGroup is updated. """ hostgroup = make_hostgroup() for new_name in valid_hostgroups_list(): with self.subTest(new_name): HostGroup.update({ 'id': hostgroup['id'], 'new-name': new_name, }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], new_name)
def test_positive_list_parameters_by_hostgroup_name(self): """List all the parameters included in specific HostGroup by its name. @id: a2a01ca7-4dd2-4db6-a654-a632864998d9 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({ 'id': sc_param_id, 'override': 1, }) sc_param = SmartClassParameter.info({ 'puppet-class': 'ntp', 'id': sc_param_id, }) self.assertEqual(sc_param['override'], True) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) hostgroup_sc_params = HostGroup.sc_params({ u'hostgroup': hostgroup['name']}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_positive_list_parameters_by_hostgroup_id(self): """List all the parameters included in specific HostGroup by id. @id: 80c1058d-b87d-4c09-957f-7d3daacdedf4 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({ 'id': sc_param_id, 'override': 1, }) sc_param = SmartClassParameter.info({ 'puppet-class': 'ntp', 'id': sc_param_id, }) self.assertEqual(sc_param['override'], True) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) hostgroup_sc_params = HostGroup.sc_params({ u'hostgroup-id': hostgroup['id']}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_negative_update_content_source(hostgroup, content_source): """Attempt to update hostgroup's content source with invalid value :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26 :BZ: 1260697, 1313056 :expectedresults: Host group was not updated. Content source remains the same as it was before update :CaseLevel: Integration """ with pytest.raises(CLIReturnCodeError): HostGroup.update({'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999)}) hostgroup = HostGroup.info({'id': hostgroup['id']}) assert hostgroup['content-source']['name'] == content_source['name']
def test_positive_list_scparams_by_id(self): """List all overridden smart class parameters using hostgroup id :id: 42a24060-2ed7-427e-8396-86d73bbe5f69 :expectedresults: Overridden sc-param from puppet class is listed :Caselevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_class['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Override one of the sc-params from puppet class sc_params_list = SmartClassParameter.list({ 'environment': self.env['name'], 'search': u'puppetclass="{0}"'.format(self.puppet_class['name']) }) scp_id = choice(sc_params_list)['id'] SmartClassParameter.update({'id': scp_id, 'override': 1}) # Verify that affected sc-param is listed hg_scparams = HostGroup.sc_params({'hostgroup-id': hostgroup['id']}) self.assertIn(scp_id, [scp['id'] for scp in hg_scparams])
def test_positive_list_scparams_by_name(self): """List all smart class parameters using hostgroup name :id: 8e4fc561-2446-4a89-989b-e6814973aa56 :expectedresults: Overridden sc-param from puppet class is listed :CaseLevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_classes[0]['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Override one of the sc-params from puppet class sc_params_list = SmartClassParameter.list({ 'environment': self.env['name'], 'search': u'puppetclass="{0}"'.format(self.puppet_classes[0]['name']) }) scp_id = choice(sc_params_list)['id'] SmartClassParameter.update({'id': scp_id, 'override': 1}) # Verify that affected sc-param is listed hg_scparams = HostGroup.sc_params({'hostgroup': hostgroup['name']}) self.assertIn(scp_id, [scp['id'] for scp in hg_scparams])
def test_positive_list_scparams_by_id(self): """List all overridden smart class parameters using hostgroup id :id: 42a24060-2ed7-427e-8396-86d73bbe5f69 :expectedresults: Overridden sc-param from puppet class is listed :Caselevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_classes[0]['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Override one of the sc-params from puppet class sc_params_list = SmartClassParameter.list({ 'environment': self.env['name'], 'search': u'puppetclass="{0}"'.format( self.puppet_classes[0]['name']) }) scp_id = choice(sc_params_list)['id'] SmartClassParameter.update({'id': scp_id, 'override': 1}) # Verify that affected sc-param is listed hg_scparams = HostGroup.sc_params({'hostgroup-id': hostgroup['id']}) self.assertIn(scp_id, [scp['id'] for scp in hg_scparams])
def test_positive_list_smartvariables_by_name(self): """List all smart variables using hostgroup name :id: 2b0da695-57fa-4f91-b164-e1ff60076c26 :expectedresults: Smart variable from puppet class is listed :CaseLevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_classes[0]['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Create smart variable smart_variable = make_smart_variable( {'puppet-class': self.puppet_classes[0]['name']}) # Verify that affected sc-param is listed hg_variables = HostGroup.smart_variables( {'hostgroup': hostgroup['name']}) self.assertIn(smart_variable['id'], [sv['id'] for sv in hg_variables])
def test_positive_delete_by_id(self): """Create HostGroup with valid values then delete it by ID :id: fe7dedd4-d7c3-4c70-b70d-c2deff357b76 :expectedresults: HostGroup is deleted :CaseImportance: Critical """ for name in valid_hostgroups_list(): with self.subTest(name): hostgroup = make_hostgroup({'name': name}) HostGroup.delete({'id': hostgroup['id']}) with self.assertRaises(CLIReturnCodeError): HostGroup.info({'id': hostgroup['id']})
def test_positive_list_parameters_by_hostgroup_id(self): """List all the parameters included in specific HostGroup by id. @id: 80c1058d-b87d-4c09-957f-7d3daacdedf4 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({ 'id': sc_param_id, 'override': 1, }) sc_param = SmartClassParameter.info({ 'puppet-class': 'ntp', 'id': sc_param_id, }) self.assertEqual(sc_param['override'], True) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet['id'] }) hostgroup_sc_params = HostGroup.sc_params( {u'hostgroup-id': hostgroup['id']}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_positive_list_parameters_by_hostgroup_name(self): """List all the parameters included in specific HostGroup by its name. @id: a2a01ca7-4dd2-4db6-a654-a632864998d9 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({ 'id': sc_param_id, 'override': 1, }) sc_param = SmartClassParameter.info({ 'puppet-class': 'ntp', 'id': sc_param_id, }) self.assertEqual(sc_param['override'], True) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet['id'] }) hostgroup_sc_params = HostGroup.sc_params( {u'hostgroup': hostgroup['name']}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_positive_list_smartvariables_by_id(self): """List all smart variables using hostgroup id :id: 1d614441-7ef9-4fdb-a8e7-2f1c1054bf2f :expectedresults: Smart variable from puppet class is listed :CaseLevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_classes[0]['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Create smart variable smart_variable = make_smart_variable( {'puppet-class': self.puppet_classes[0]['name']}) # Verify that affected sc-param is listed hg_variables = HostGroup.smart_variables( {'hostgroup-id': hostgroup['id']}) self.assertIn(smart_variable['id'], [sv['id'] for sv in hg_variables])
def test_negative_update_name(self): """Create HostGroup then fail to update its name @feature: HostGroup @assert: HostGroup name is not updated """ hostgroup = make_hostgroup() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): HostGroup.update({ 'id': hostgroup['id'], 'new-name': new_name, }) result = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], result['name'])
def test_negative_create_with_domain_id(self): """Check if hostgroup with invalid domain id raises proper error @id: b36c83d6-b27c-4f1a-ac45-6c4999005bf7 @Assert: Proper error should be raised @BZ: 1354568 """ domain_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'domain-id': domain_id }) self.assertIs(exception.exception.stderr, 'Could not find domain {0}'.format(domain_id))
def test_negative_create_with_architecture_id(self): """Check if hostgroup with invalid architecture id raises proper error @id: 7b7de0fa-aee9-4163-adc2-354c1e720d90 @Assert: Proper error should be raised @BZ: 1354568 """ arch_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'architecture-id': arch_id }) self.assertIs(exception.exception.stderr, 'Could not find architecture {0}'.format(arch_id))
def test_negative_update_name(self): """Create HostGroup then fail to update its name @id: 42d208a4-f518-4ff2-9b7a-311adb460abd @assert: HostGroup name is not updated """ hostgroup = make_hostgroup() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): HostGroup.update({ 'id': hostgroup['id'], 'new-name': new_name, }) result = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], result['name'])
def test_negative_create_with_subnet_id(self): """Check if hostgroup with invalid subnet id raises proper error @id: c352d7ea-4fc6-4b78-863d-d3ee4c0ad439 @Assert: Proper error should be raised @BZ: 1354568 """ subnet_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'subnet-id': subnet_id }) self.assertIs(exception.exception.stderr, 'Could not find subnet {0}'.format(subnet_id))
def test_negative_create_with_domain_id(self): """Check if hostgroup with invalid domain id raises proper error @id: b36c83d6-b27c-4f1a-ac45-6c4999005bf7 @Assert: Proper error should be raised @BZ: 1354568 """ domain_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'domain-id': domain_id }) self.assertIs( exception.exception.stderr, 'Could not find domain {0}'.format(domain_id) )
def test_positive_update_hostgroup(self): """Update hostgroup's content source, name and puppet classes :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source, name and puppet classes :CaseLevel: Integration """ hostgroup = make_hostgroup({ 'content-source-id': self.content_source['id'], 'organization-ids': self.org['id'], 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) self.assertEqual(len(hostgroup['puppetclasses']), 0) new_name = valid_hostgroups_list()[0] puppet_classes = [puppet['name'] for puppet in self.puppet_classes] HostGroup.update({ 'new-name': new_name, 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], 'puppet-classes': puppet_classes, }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], new_name) self.assertEqual(hostgroup['content-source']['name'], new_content_source['name']) self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
def test_negative_create_with_subnet_id(self): """Check if hostgroup with invalid subnet id raises proper error @id: c352d7ea-4fc6-4b78-863d-d3ee4c0ad439 @Assert: Proper error should be raised @BZ: 1354568 """ subnet_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'subnet-id': subnet_id }) self.assertIs( exception.exception.stderr, 'Could not find subnet {0}'.format(subnet_id) )
def test_negative_update_name(self): """Create HostGroup then fail to update its name :id: 42d208a4-f518-4ff2-9b7a-311adb460abd :expectedresults: HostGroup name is not updated :CaseImportance: Critical """ hostgroup = make_hostgroup() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): HostGroup.update({ 'id': hostgroup['id'], 'new-name': new_name, }) result = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], result['name'])
def test_negative_create_with_architecture_id(self): """Check if hostgroup with invalid architecture id raises proper error @id: 7b7de0fa-aee9-4163-adc2-354c1e720d90 @Assert: Proper error should be raised @BZ: 1354568 """ arch_id = gen_string('numeric', 4) with self.assertRaises(CLIReturnCodeError) as exception: HostGroup.create({ 'name': gen_string('alpha'), 'architecture-id': arch_id }) self.assertIs( exception.exception.stderr, 'Could not find architecture {0}'.format(arch_id) )
def test_positive_update_puppet_class_by_name(self): """Update hostgroup with puppet class by name :id: 4c37354f-ef2d-4d54-98ac-906bc611d292 :expectedresults: Puppet class is associated with hostgroup :CaseImportance: Critical """ hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) self.assertEqual(len(hostgroup['puppetclasses']), 0) HostGroup.update({ 'id': hostgroup['id'], 'puppet-classes': self.puppet_classes[0]['name'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertIn(self.puppet_classes[0]['name'], hostgroup['puppetclasses'])
def test_positive_update_puppet_class_by_name(self): """Update hostgroup with puppet class by name :id: 4c37354f-ef2d-4d54-98ac-906bc611d292 :expectedresults: Puppet class is associated with hostgroup :CaseImportance: Critical """ hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) self.assertEqual(len(hostgroup['puppetclasses']), 0) HostGroup.update({ 'id': hostgroup['id'], 'puppet-classes': self.puppet_classes[0]['name'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertIn( self.puppet_classes[0]['name'], hostgroup['puppetclasses'])
def test_positive_update_puppet_class_by_id(self): """Update hostgroup with puppet class by name by id :id: 4b044719-431d-4d72-8974-330cc62fd020 :expectedresults: Puppet class is associated with hostgroup :CaseImportance: Critical """ hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) self.assertEqual(len(hostgroup['puppetclasses']), 0) HostGroup.update({ 'id': hostgroup['id'], 'puppet-class-ids': self.puppet_classes[0]['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertIn( self.puppet_classes[0]['name'], hostgroup['puppetclasses'])
def test_positive_update_multiple_puppet_classes(self): """Update hostgroup with multiple puppet classes by name :id: 2e977aed-c0d4-478e-9c84-f07deac912cd :expectedresults: All puppet classes are associated with hostgroup :BZ: 1264163 :CaseImportance: Critical """ puppet_classes = [puppet['name'] for puppet in self.puppet_classes] hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) self.assertEqual(len(hostgroup['puppetclasses']), 0) HostGroup.update({ 'id': hostgroup['id'], 'puppet-classes': puppet_classes}) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
def test_positive_list_parameters_by_hostgroup_id(self): """List all the parameters included in specific HostGroup by id. @id: 80c1058d-b87d-4c09-957f-7d3daacdedf4 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({"id": sc_param_id, "override": 1}) sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id}) self.assertEqual(sc_param["override"], True) hostgroup = make_hostgroup({"environment-id": self.env["id"], "puppet-class-ids": self.puppet["id"]}) hostgroup_sc_params = HostGroup.sc_params({u"hostgroup-id": hostgroup["id"]}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_positive_list_parameters_by_hostgroup_name(self): """List all the parameters included in specific HostGroup by its name. @id: a2a01ca7-4dd2-4db6-a654-a632864998d9 @assert: Parameters listed for specific HostGroup. @CaseLevel: Integration """ sc_param_id = self.sc_params_ids_list.pop() SmartClassParameter.update({"id": sc_param_id, "override": 1}) sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id}) self.assertEqual(sc_param["override"], True) hostgroup = make_hostgroup({"environment-id": self.env["id"], "puppet-class-ids": self.puppet["id"]}) hostgroup_sc_params = HostGroup.sc_params({u"hostgroup": hostgroup["name"]}) self.assertGreater(len(hostgroup_sc_params), 0)
def test_positive_list_variables_by_hostgroup_id(self): """List all smart variables associated to hostgroup by hostgroup id @id: 0f167c4c-e4de-4b66-841f-d5a9e410391e @assert: Smart Variables listed for specific HostGroup by hostgroup id. @CaseLevel: Integration """ make_smart_variable({'puppet-class': self.puppet_class['name']}) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) hostgroup_smart_variables = HostGroup.smart_variables({ u'hostgroup-id': hostgroup['id']}) self.assertGreater(len(hostgroup_smart_variables), 0)
def test_positive_list_variables_by_hostgroup_name(self): """List all smart variables associated to hostgroup by hostgroup name @id: cb69abe0-2349-4114-91e9-ef93f261dc50 @assert: Smart Variables listed for specific HostGroup by hostgroup name. @CaseLevel: Integration """ make_smart_variable({'puppet-class': self.puppet_class['name']}) hostgroup = make_hostgroup({ 'environment-id': self.env['id'], 'puppet-class-ids': self.puppet_class['id'] }) hostgroup_smart_variables = HostGroup.smart_variables({ u'hostgroup': hostgroup['name']}) self.assertGreater(len(hostgroup_smart_variables), 0)
def test_positive_list_smartvariables_by_name(self): """List all smart variables using hostgroup name :id: 2b0da695-57fa-4f91-b164-e1ff60076c26 :expectedresults: Smart variable from puppet class is listed :Caselevel: Integration """ # Create hostgroup with associated puppet class hostgroup = make_hostgroup({ 'puppet-classes': self.puppet_classes[0]['name'], 'environment': self.env['name'], 'content-view': self.cv['name'], 'query-organization': self.org['name'], }) # Create smart variable smart_variable = make_smart_variable( {'puppet-class': self.puppet_classes[0]['name']}) # Verify that affected sc-param is listed hg_variables = HostGroup.smart_variables( {'hostgroup': hostgroup['name']}) self.assertIn(smart_variable['id'], [sv['id'] for sv in hg_variables])