def test_positive_delete_by_name(self): """Check if host collection can be created and deleted by name :id: a841a9f8-4285-40e5-9670-3f379dfd9a1e :customerscenario: true :expectedresults: Host collection is created and then deleted :BZ: 1328925 :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): new_host_col = make_host_collection({ 'name': name, 'organization-id': self.organization['id'], }) HostCollection.delete({ 'name': new_host_col['name'], 'organization-id': self.organization['id'], }) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_remove_chost_by_id(self): """Check if content host can be removed from host collection @Feature: Host Collection @Assert: Host collection is created and content-host is removed """ new_host_col = self._new_host_collection({ 'name': gen_string('alpha', 15)}) new_system = make_content_host({ u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id'], u'name': gen_string('alpha', 15), u'organization-id': self.org['id'], }) HostCollection.add_host({ u'hosts': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) no_of_content_host = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] })['total-hosts'] HostCollection.remove_host({ u'hosts': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'], }) self.assertGreater(no_of_content_host, result['total-hosts'])
def test_positive_update_to_unlimited_hosts(module_org): """Create Host Collection with a limit and update it to unlimited hosts :id: d688fd4a-88eb-484e-9e90-854e0595edd0 :expectedresults: Host Collection is created and updated to unlimited hosts :CaseImportance: High """ host_collection = make_host_collection({ 'max-hosts': 1, 'organization-id': module_org.id, }) result = HostCollection.info({ 'name': host_collection['name'], 'organization-id': module_org.id }) assert result['limit'] == '1' HostCollection.update({ 'name': host_collection['name'], 'organization-id': module_org.id, 'unlimited-hosts': True, }) result = HostCollection.info({ 'name': host_collection['name'], 'organization-id': module_org.id }) assert result['limit'] == 'None'
def test_positive_remove_host_by_name(self): """Check if content host can be removed from host collection by name :id: 924d0137-3a9e-4ecd-9631-c21f7e9a8d5d :customerscenario: true :expectedresults: Host collection is created and content-host is removed :CaseLevel: Integration """ new_host_col = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'], }) new_system = self._make_fake_host_helper() HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], }) no_of_content_host = HostCollection.info({ u'id': new_host_col['id'], })['total-hosts'] HostCollection.remove_host({ u'host-ids': new_system['id'], u'name': new_host_col['name'], u'organization': self.organization['name'], }) result = HostCollection.info({ u'id': new_host_col['id'], }) self.assertGreater(no_of_content_host, result['total-hosts'])
def test_remove_content_host(self): """@Test: Check if content host can be removed from host collection @Feature: Host Collection @Assert: Host collection is created and content-host is removed """ host_col_name = generate_string('alpha', 15) content_host_name = generate_string('alpha', 15) try: new_host_col = self._new_host_collection({'name': host_col_name}) new_system = make_content_host({ u'name': content_host_name, u'organization-id': self.org['id'], u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id']}) except CLIFactoryError as err: self.fail(err) result = HostCollection.add_content_host({ u'id': new_host_col['id'], u'organization-id': self.org['id'], u'content-host-ids': new_system['id'] }) self.assertEqual(result.return_code, 0, "Content Host not added to host collection") self.assertEqual(len(result.stderr), 0, "No error was expected") result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) no_of_content_host = result.stdout['total-content-hosts'] result = HostCollection.remove_content_host({ u'id': new_host_col['id'], u'organization-id': self.org['id'], u'content-host-ids': new_system['id'] }) self.assertEqual(result.return_code, 0, "Content Host not removed host collection") self.assertEqual(len(result.stderr), 0, "No error was expected") result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertEqual( result.return_code, 0, 'Failed to get info for host collection') self.assertEqual( len(result.stderr), 0, 'There should not be an error here') self.assertGreater(no_of_content_host, result.stdout['total-content-hosts'], "There should not be an exception here")
def test_positive_remove_host_by_id(self): """Check if content host can be removed from host collection @id: 61f4aab1-398b-4d3a-a4f4-f558ad8d2679 @Assert: Host collection is created and content-host is removed @CaseLevel: Integration """ new_host_col = self._new_host_collection({ 'name': gen_string('alpha', 15) }) new_system = self._make_content_host_helper() HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) no_of_content_host = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] })['total-hosts'] HostCollection.remove_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'], }) self.assertGreater(no_of_content_host, result['total-hosts'])
def test_positive_remove_chost_by_id(self): """Check if content host can be removed from host collection @Feature: Host Collection @Assert: Host collection is created and content-host is removed """ new_host_col = self._new_host_collection({"name": gen_string("alpha", 15)}) new_system = make_content_host( { u"content-view-id": self.default_cv["id"], u"lifecycle-environment-id": self.library["id"], u"name": gen_string("alpha", 15), u"organization-id": self.org["id"], } ) HostCollection.add_content_host( {u"content-host-ids": new_system["id"], u"id": new_host_col["id"], u"organization-id": self.org["id"]} ) no_of_content_host = HostCollection.info({u"id": new_host_col["id"], u"organization-id": self.org["id"]})[ "total-content-hosts" ] HostCollection.remove_content_host( {u"content-host-ids": new_system["id"], u"id": new_host_col["id"], u"organization-id": self.org["id"]} ) result = HostCollection.info({u"id": new_host_col["id"], u"organization-id": self.org["id"]}) self.assertGreater(no_of_content_host, result["total-content-hosts"])
def test_add_content_host(self): """@Test: Check if content host can be added to host collection @Feature: Host Collection @Assert: Host collection is created and content-host is added """ host_col_name = gen_string('alpha', 15) content_host_name = gen_string('alpha', 15) try: new_host_col = self._new_host_collection({'name': host_col_name}) new_system = make_content_host({ u'name': content_host_name, u'organization-id': self.org['id'], u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id'], }) except CLIFactoryError as err: self.fail(err) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) no_of_content_host = result.stdout['total-content-hosts'] result = HostCollection.add_content_host({ u'id': new_host_col['id'], u'organization-id': self.org['id'], u'content-host-ids': new_system['id'] }) self.assertEqual(result.return_code, 0, "Content Host not added to host collection") self.assertEqual(len(result.stderr), 0, "No error was expected") result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertEqual(result.return_code, 0, 'Failed to get info for host collection') self.assertEqual(len(result.stderr), 0, 'There should not be an error here') self.assertGreater(result.stdout['total-content-hosts'], no_of_content_host, "There should not be an exception here")
def test_positive_delete_by_id(self): """Check if host collection can be created and deleted @Feature: Host Collection @Assert: Host collection is created and then deleted """ for name in valid_data_list(): with self.subTest(name): new_host_col = self._new_host_collection({"name": name}) HostCollection.delete({"id": new_host_col["id"], "organization-id": self.org["id"]}) with self.assertRaises(CLIReturnCodeError): HostCollection.info({"id": new_host_col["id"]})
def test_positive_copy_by_id(self): """Check if host collection can be cloned by id :id: fd7cea50-bc56-4938-a81d-4f7a60711814 :customerscenario: true :expectedresults: Host collection is cloned successfully :BZ: 1328925 :CaseLevel: Integration """ host_collection = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'] }) new_name = gen_string('numeric') new_host_collection = HostCollection.copy({ 'id': host_collection['id'], 'new-name': new_name }) result = HostCollection.info({'id': new_host_collection[0]['id']}) self.assertEqual(result['name'], new_name)
def test_positive_copy_by_name(self): """Check if host collection can be cloned by name :id: ca9be8de-ea9a-4890-8890-a1809a85a4ff :customerscenario: true :expectedresults: Host collection is cloned successfully :BZ: 1328925 :CaseLevel: Integration """ host_collection = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'], }) new_name = gen_string('numeric') new_host_collection = HostCollection.copy({ u'name': host_collection['name'], u'new-name': new_name, u'organization-label': self.organization['label'], }) result = HostCollection.info({ u'id': new_host_collection[0]['id'], }) self.assertEqual(result['name'], new_name)
def test_positive_list_by_host_id(self): """Check if host collection list can be filtered by associated host id :id: de272461-9804-4524-83c8-23e47abfc8e3 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'host-ids': host['id'], 'id': host_col['id'], }) host_col = HostCollection.info({ 'id': host_col['id'], }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list( {'organization-id': self.organization['id']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host id result = HostCollection.list({'host-id': host['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_add_host_by_name(self): """Check if content host can be added to host collection by name :id: fe468f76-4693-4509-b534-126fce187194 :customerscenario: true :expectedresults: Host collection is created and content-host is added :CaseLevel: Integration """ new_host_col = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'], }) new_system = self._make_fake_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'hosts': new_system['name'], u'name': new_host_col['name'], u'organization': self.organization['name'], }) result = HostCollection.info({ u'name': new_host_col['name'], u'organization': self.organization['name'], }) self.assertGreater(result['total-hosts'], no_of_content_host)
def test_positive_create_with_unlimited_hosts(module_org): """Create Host Collection with different values of unlimited-hosts parameter :id: d688fd4a-88eb-484e-9e90-854e0595edd0 :expectedresults: Host Collection is created and unlimited-hosts parameter is set :CaseImportance: Critical """ for unlimited in ('True', 'Yes', 1, 'False', 'No', 0): host_collection = make_host_collection( { 'max-hosts': 1 if unlimited in ('False', 'No', 0) else None, 'organization-id': module_org.id, 'unlimited-hosts': unlimited, } ) result = HostCollection.info( {'name': host_collection['name'], 'organization-id': module_org.id} ) if unlimited in ('True', 'Yes', 1): assert result['limit'] == 'None' else: assert result['limit'] == '1'
def test_add_content_host(self): """@Test: Check if content host can be added to host collection @Feature: Host Collection @Assert: Host collection is created and content-host is added """ new_host_col = self._new_host_collection({ 'name': gen_string('alpha', 15)}) new_system = make_content_host({ u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id'], u'name': gen_string('alpha', 15), u'organization-id': self.org['id'], }) no_of_content_host = new_host_col['total-content-hosts'] HostCollection.add_content_host({ u'content-host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertGreater(result['total-content-hosts'], no_of_content_host)
def test_positive_add_host_by_id(self): """Check if content host can be added to host collection @id: db987da4-6326-43d5-a4c5-93a0c4da7f00 @Assert: Host collection is created and content-host is added @CaseLevel: Integration """ new_host_col = self._new_host_collection({ 'name': gen_string('alpha', 15)}) new_system = make_content_host({ u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id'], u'name': gen_string('alpha', 15), u'organization-id': self.org['id'], }) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertGreater(result['total-hosts'], no_of_content_host)
def test_positive_delete_1(self, test_data): """@Test: Check if host collection can be created and deleted @Feature: Host Collection @Assert: Host collection is created and then deleted """ new_host_col = self._new_host_collection({'name': test_data['name']}) # Assert that name matches data passed self.assertEqual(new_host_col['name'], test_data['name'], "Names don't match") # Delete it result = HostCollection.delete({ 'id': new_host_col['id'], 'organization-id': self.org['id'] }) self.assertEqual(result.return_code, 0, "Host collection was not deleted") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = HostCollection.info({ 'id': new_host_col['id'], }) self.assertNotEqual(result.return_code, 0, "Host collection should not be found") self.assertGreater(len(result.stderr), 0, "Expected an error here")
def test_positive_add_host_by_id(self): """Check if content host can be added to host collection by id :id: db987da4-6326-43d5-a4c5-93a0c4da7f00 :expectedresults: Host collection is created and content-host is added :CaseLevel: Integration """ new_host_col = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'], }) new_system = self._make_fake_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], }) self.assertGreater(result['total-hosts'], no_of_content_host)
def test_positive_copy_by_id(self): """Check if host collection can be cloned by id :id: fd7cea50-bc56-4938-a81d-4f7a60711814 :customerscenario: true :expectedresults: Host collection is cloned successfully :BZ: 1328925 :CaseLevel: Integration """ host_collection = make_host_collection({ 'name': gen_string('alpha', 15), 'organization-id': self.organization['id'], }) new_name = gen_string('numeric') new_host_collection = HostCollection.copy({ u'id': host_collection['id'], u'new-name': new_name, }) result = HostCollection.info({ u'id': new_host_collection[0]['id'], }) self.assertEqual(result['name'], new_name)
def test_positive_update_3(self, test_data): """ @Test: Check if host collection limits be updated @Feature: Host Collection @Assert: Host collection limits is updated @BZ: 1084240 """ new_host_col = self._new_host_collection() # Update sync interval result = HostCollection.update({ 'id': new_host_col['id'], 'organization-id': self.org['id'], 'max-content-hosts': test_data }) self.assertEqual(result.return_code, 0, "Host collection was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = HostCollection.info({ 'id': new_host_col['id'], }) self.assertEqual(result.return_code, 0, "Host collection was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Assert that limit was updated self.assertEqual(result.stdout['max-content-hosts'], test_data, "Limits don't match") self.assertNotEqual(new_host_col['max-content-hosts'], result.stdout['max-content-hosts'], "Limits don't match")
def test_positive_list_hosts(self): """Check if content hosts added to host collection is listed @id: 3075cb97-8448-4358-8ffc-0d5cd0078ca3 @Assert: Content-host added to host-collection is listed @CaseLevel: Integration """ host_col_name = gen_string('alpha', 15) new_host_col = self._new_host_collection({'name': host_col_name}) new_system = self._make_content_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertGreater(result['total-hosts'], no_of_content_host) result = HostCollection.hosts({ u'name': host_col_name, u'organization-id': self.org['id'] }) self.assertEqual(new_system['name'].lower(), result[0]['name'])
def test_positive_list_chosts(self): """Check if content hosts added to host collection is listed @Feature: Host Collection @Assert: Content-host added to host-collection is listed """ host_col_name = gen_string("alpha", 15) new_host_col = self._new_host_collection({"name": host_col_name}) new_system = make_content_host( { u"content-view-id": self.default_cv["id"], u"lifecycle-environment-id": self.library["id"], u"name": gen_string("alpha", 15), u"organization-id": self.org["id"], } ) no_of_content_host = new_host_col["total-content-hosts"] HostCollection.add_content_host( {u"content-host-ids": new_system["id"], u"id": new_host_col["id"], u"organization-id": self.org["id"]} ) result = HostCollection.info({u"id": new_host_col["id"], u"organization-id": self.org["id"]}) self.assertGreater(result["total-content-hosts"], no_of_content_host) result = HostCollection.content_hosts({u"name": host_col_name, u"organization-id": self.org["id"]}) self.assertEqual(new_system["id"], result[0]["id"])
def test_positive_list_by_host_id(self): """Check if host collection list can be filtered by associated host id :id: de272461-9804-4524-83c8-23e47abfc8e3 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'host-ids': host['id'], 'id': host_col['id'], }) host_col = HostCollection.info({ 'id': host_col['id'], }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list({ 'organization-id': self.organization['id']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host id result = HostCollection.list({'host-id': host['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_create_hc_with_unlimited_content_hosts(self, unlimited): """@Test: Create Host Collection with different values of unlimited-content-hosts parameter @Feature: Host Collection - Unlimited Content Hosts @Assert: Host Collection is created and unlimited-content-hosts parameter is set @BZ: 1214675 """ try: host_collection = make_host_collection({ u'organization-id': self.org['id'], u'unlimited-content-hosts': unlimited, }) except CLIFactoryError as err: self.fail(err) result = HostCollection.info({ u'id': host_collection['id'], u'organization-id': self.org['id'], }) if unlimited in (u'True', u'Yes', 1): self.assertEqual( result.stdout['unlimited-content-hosts'], u'true') else: self.assertEqual( result.stdout['unlimited-content-hosts'], u'false')
def test_positive_list_hosts(self): """Check if content hosts added to host collection is listed @Feature: Host Collection @Assert: Content-host added to host-collection is listed """ host_col_name = gen_string('alpha', 15) new_host_col = self._new_host_collection({'name': host_col_name}) new_system = make_content_host({ u'content-view-id': self.default_cv['id'], u'lifecycle-environment-id': self.library['id'], u'name': gen_string('alpha', 15), u'organization-id': self.org['id'], }) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'hosts': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertGreater(result['total-hosts'], no_of_content_host) result = HostCollection.content_hosts({ u'name': host_col_name, u'organization-id': self.org['id'] }) self.assertEqual(new_system['id'], result[0]['id'])
def test_positive_update_1(self, test_data): """@Test: Check if host collection name can be updated @Feature: Host Collection @Assert: Host collection is created and name is updated """ new_host_col = self._new_host_collection() # Assert that name does not matches data passed self.assertNotEqual(new_host_col['name'], test_data['name']) # Update host collection result = HostCollection.update({ 'id': new_host_col['id'], 'organization-id': self.org['id'], 'name': test_data['name'] }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Fetch it result = HostCollection.info({ 'id': new_host_col['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Assert that name matches new value self.assertIsNotNone(result.stdout.get('name', None)) self.assertEqual(result.stdout['name'], test_data['name']) # Assert that name does not match original value self.assertNotEqual(new_host_col['name'], result.stdout['name'])
def test_positive_create_with_unlimited_hosts(self): """Create Host Collection with different values of unlimited-hosts parameter @Feature: Host Collection - Unlimited Hosts @Assert: Host Collection is created and unlimited-hosts parameter is set @BZ: 1214675 """ for unlimited in (u'True', u'Yes', 1, u'False', u'No', 0): with self.subTest(unlimited): host_collection = make_host_collection({ u'organization-id': self.org['id'], u'unlimited-hosts': unlimited, }) result = HostCollection.info({ u'id': host_collection['id'], u'organization-id': self.org['id'], }) if unlimited in (u'True', u'Yes', 1): self.assertEqual( result['unlimited-hosts'], u'true') else: self.assertEqual( result['unlimited-hosts'], u'false')
def test_positive_update_3(self, test_data): """@Test: Check if host collection limits be updated @Feature: Host Collection @Assert: Host collection limits is updated @BZ: 1245334 """ new_host_col = self._new_host_collection() # Update sync interval result = HostCollection.update({ 'id': new_host_col['id'], 'organization-id': self.org['id'], 'max-content-hosts': test_data }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Fetch it result = HostCollection.info({ 'id': new_host_col['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Assert that limit was updated self.assertEqual(result.stdout['limit'], test_data) self.assertNotEqual( new_host_col['limit'], result.stdout['limit'] )
def test_positive_delete_1(self, test_data): """@Test: Check if host collection can be created and deleted @Feature: Host Collection @Assert: Host collection is created and then deleted """ new_host_col = self._new_host_collection({'name': test_data['name']}) # Assert that name matches data passed self.assertEqual(new_host_col['name'], test_data['name']) # Delete it result = HostCollection.delete( {'id': new_host_col['id'], 'organization-id': self.org['id']}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Fetch it result = HostCollection.info( { 'id': new_host_col['id'], } ) self.assertNotEqual(result.return_code, 0) self.assertGreater(len(result.stderr), 0)
def _new_host_collection(self, options=None): """Make a host collection and asserts its success""" if options is None: options = {} if not options.get('organization-id', None): options['organization-id'] = self.org['id'] group = make_host_collection(options) # Fetch it result = HostCollection.info( { 'id': group['id'] } ) self.assertEqual( result.return_code, 0, "Host collection was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") # Return the host collection dictionary return group
def test_positive_create_with_unlimited_hosts(self): """Create Host Collection with different values of unlimited-hosts parameter @id: d688fd4a-88eb-484e-9e90-854e0595edd0 @Assert: Host Collection is created and unlimited-hosts parameter is set """ for unlimited in ('True', 'Yes', 1, 'False', 'No', 0): with self.subTest(unlimited): host_collection = make_host_collection({ 'max-hosts': 1 if unlimited in ('False', 'No', 0) else None, 'organization-id': self.org['id'], 'unlimited-hosts': unlimited, }) result = HostCollection.info({ 'id': host_collection['id'], 'organization-id': self.org['id'], }) if unlimited in ('True', 'Yes', 1): self.assertEqual(result['limit'], 'None') else: self.assertEqual(result['limit'], '1')
def test_positive_update_2(self, test_data): """ @Test: Check if host collection description can be updated @Feature: Host Collection @Assert: Host collection is created and description is updated @BZ: 1084240 """ new_host_col = self._new_host_collection() # Assert that description does not match data passed self.assertNotEqual( new_host_col['description'], test_data['description'], "Descriptions should not match" ) # Update sync plan result = HostCollection.update( { 'id': new_host_col['id'], 'organization-id': self.org['id'], 'description': test_data['description'] } ) self.assertEqual( result.return_code, 0, "Host collection was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = HostCollection.info( { 'id': new_host_col['id'], } ) self.assertEqual( result.return_code, 0, "Host collection was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Assert that description matches new value self.assertIsNotNone( result.stdout.get('description', None), "The description field was not returned" ) self.assertEqual( result.stdout['description'], test_data['description'], "Descriptions should match" ) # Assert that description does not matches original value self.assertNotEqual( new_host_col['description'], result.stdout['description'], "Descriptions should not match" )
def test_positive_delete_by_id(self): """Check if host collection can be created and deleted @Feature: Host Collection @Assert: Host collection is created and then deleted """ for name in valid_data_list(): with self.subTest(name): new_host_col = self._new_host_collection({'name': name}) HostCollection.delete({ 'id': new_host_col['id'], 'organization-id': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_delete_1(self): """@Test: Check if host collection can be created and deleted @Feature: Host Collection @Assert: Host collection is created and then deleted """ for name in valid_data_list(): with self.subTest(name): new_host_col = self._new_host_collection({'name': name}) HostCollection.delete({ 'id': new_host_col['id'], 'organization-id': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_delete_by_id(self): """Check if host collection can be created and deleted @id: ef54a26e-a18f-4f29-8ef4-a7124785dbae @Assert: Host collection is created and then deleted @BZ: 1328925 """ for name in valid_data_list(): with self.subTest(name): new_host_col = self._new_host_collection({'name': name}) HostCollection.delete({ 'id': new_host_col['id'], 'organization-id': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_delete_by_id(self): """Check if host collection can be created and deleted by id :id: ef54a26e-a18f-4f29-8ef4-a7124785dbae :expectedresults: Host collection is created and then deleted :BZ: 1328925 :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): new_host_col = make_host_collection({ 'name': name, 'organization-id': self.organization['id'], }) HostCollection.delete({ 'id': new_host_col['id'], }) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_update_3(self, test_data): """@Test: Check if host collection limits be updated @Feature: Host Collection @Assert: Host collection limits is updated @BZ: 1084240 """ new_host_col = self._new_host_collection() # Update sync interval result = HostCollection.update( { 'id': new_host_col['id'], 'organization-id': self.org['id'], 'max-content-hosts': test_data } ) self.assertEqual( result.return_code, 0, "Host collection was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = HostCollection.info( { 'id': new_host_col['id'], } ) self.assertEqual( result.return_code, 0, "Host collection was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Assert that limit was updated self.assertEqual( result.stdout['max-content-hosts'], test_data, "Limits don't match" ) self.assertNotEqual( new_host_col['max-content-hosts'], result.stdout['max-content-hosts'], "Limits don't match" )
def test_positive_update_name(self): """Check if host collection name can be updated @Feature: Host Collection @Assert: Host collection is created and name is updated """ new_host_col = self._new_host_collection() for new_name in valid_data_list(): with self.subTest(new_name): HostCollection.update({"id": new_host_col["id"], "name": new_name, "organization-id": self.org["id"]}) result = HostCollection.info({"id": new_host_col["id"]}) self.assertEqual(result["name"], new_name)
def test_positive_update_description(self): """Check if host collection description can be updated @Feature: Host Collection @Assert: Host collection is created and description is updated """ new_host_col = self._new_host_collection() for desc in valid_data_list(): with self.subTest(desc): HostCollection.update( {"description": desc, "id": new_host_col["id"], "organization-id": self.org["id"]} ) result = HostCollection.info({"id": new_host_col["id"]}) self.assertEqual(result["description"], desc)
def test_positive_update_limit(module_org): """Check if host collection limits can be updated :id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec :expectedresults: Host collection limits is updated :BZ: 1245334 :CaseImportance: Critical """ new_host_col = make_host_collection({'organization-id': module_org.id}) for limit in ('3', '6', '9', '12', '15', '17', '19'): HostCollection.update({'id': new_host_col['id'], 'max-hosts': limit, 'unlimited-hosts': 0}) result = HostCollection.info({'id': new_host_col['id']}) assert result['limit'] == limit
def test_positive_update_name(self): """Check if host collection name can be updated @Feature: Host Collection @Assert: Host collection is created and name is updated """ new_host_col = self._new_host_collection() for new_name in valid_data_list(): with self.subTest(new_name): HostCollection.update({ 'id': new_host_col['id'], 'name': new_name, 'organization-id': self.org['id'], }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['name'], new_name)
def test_positive_update_description(self): """Check if host collection description can be updated @Feature: Host Collection @Assert: Host collection is created and description is updated """ new_host_col = self._new_host_collection() for desc in valid_data_list(): with self.subTest(desc): HostCollection.update({ 'description': desc, 'id': new_host_col['id'], 'organization-id': self.org['id'], }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['description'], desc)
def test_positive_update_2(self, test_data): """@Test: Check if host collection description can be updated @Feature: Host Collection @Assert: Host collection is created and description is updated @BZ: 1171669 """ new_host_col = self._new_host_collection() # Assert that description does not match data passed self.assertNotEqual(new_host_col['description'], test_data['description'], "Descriptions should not match") # Update sync plan result = HostCollection.update({ 'id': new_host_col['id'], 'organization-id': self.org['id'], 'description': test_data['description'] }) self.assertEqual(result.return_code, 0, "Host collection was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = HostCollection.info({ 'id': new_host_col['id'], }) self.assertEqual(result.return_code, 0, "Host collection was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Assert that description matches new value self.assertIsNotNone(result.stdout.get('description', None), "The description field was not returned") self.assertEqual(result.stdout['description'], test_data['description'], "Descriptions should match") # Assert that description does not matches original value self.assertNotEqual(new_host_col['description'], result.stdout['description'], "Descriptions should not match")
def test_positive_update_description(self): """Check if host collection description can be updated @id: 298b1f86-d4ab-4e10-a948-a0034826505f @Assert: Host collection is created and description is updated @BZ: 1328925 """ new_host_col = self._new_host_collection() for desc in valid_data_list(): with self.subTest(desc): HostCollection.update({ 'description': desc, 'id': new_host_col['id'], 'organization-id': self.org['id'], }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['description'], desc)
def test_positive_update_name(self): """Check if host collection name can be updated @id: 10d395e6-4ac6-4c35-a78c-c59a78c55799 @Assert: Host collection is created and name is updated @BZ: 1328925 """ new_host_col = self._new_host_collection() for new_name in valid_data_list(): with self.subTest(new_name): HostCollection.update({ 'id': new_host_col['id'], 'name': new_name, 'organization-id': self.org['id'], }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['name'], new_name)
def test_positive_list_by_host_name(self): """Check if host collection list can be filtered by associated host name :id: 2a99e11f-50b8-48b4-8dce-e6ad8ff9c051 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'hosts': host['name'], 'name': host_col['name'], 'organization': self.organization['name'], }) host_col = HostCollection.info({ 'name': host_col['name'], 'organization': self.organization['name'] }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list( {'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': host['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], host_col['name'])
def test_positive_update_limit(self): """Check if host collection limits be updated @id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec @Assert: Host collection limits is updated @BZ: 1245334 """ new_host_col = self._new_host_collection() for limit in ('3', '6', '9', '12', '15', '17', '19'): with self.subTest(limit): HostCollection.update({ 'id': new_host_col['id'], 'max-hosts': limit, 'organization-id': self.org['id'], }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['limit'], limit)
def _new_host_collection(self, options=None): """Make a host collection and asserts its success""" if options is None: options = {} if not options.get('organization-id', None): options['organization-id'] = self.org['id'] group = make_host_collection(options) # Fetch it result = HostCollection.info({'id': group['id']}) self.assertEqual(result.return_code, 0, "Host collection was not found") self.assertEqual(len(result.stderr), 0, "No error was expected") # Return the host collection dictionary return group