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_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_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_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_positive_end_to_end(module_org): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = list(valid_data_list().values())[0] desc = list(valid_data_list().values())[0] new_host_col = make_host_collection( {'description': desc, 'name': name, 'organization-id': module_org.id} ) assert new_host_col['name'] == name assert new_host_col['description'] == desc # add host new_system = _make_fake_host_helper(module_org) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert result['total-hosts'] > no_of_content_host # list hosts result = HostCollection.hosts({'name': name, 'organization-id': module_org.id}) assert new_system['name'].lower() == result[0]['name'] # List all host collections within organization result = HostCollection.list({'organization': module_org.name}) assert len(result) >= 1 # Filter list by name result = HostCollection.list({'name': name, 'organization-id': module_org.id}) assert len(result) == 1 assert result[0]['id'] == new_host_col['id'] # Filter list by associated host name result = HostCollection.list({'organization': module_org.name, 'host': new_system['name']}) assert len(result) == 1 assert result[0]['name'] == new_host_col['name'] # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id']})['total-hosts'] HostCollection.remove_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert no_of_content_host > result['total-hosts'] # update new_name = list(valid_data_list().values())[0] new_desc = list(valid_data_list().values())[0] HostCollection.update( {'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name} ) result = HostCollection.info({'id': new_host_col['id']}) assert result['name'] == new_name assert result['description'] == new_desc # delete HostCollection.delete({'id': new_host_col['id']}) with pytest.raises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_end_to_end(self): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = valid_data_list()[0] desc = valid_data_list()[0] new_host_col = make_host_collection({ 'description': desc, 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_host_col['name'], name) self.assertEqual(new_host_col['description'], desc) # add host new_system = self._make_fake_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(result['total-hosts'], no_of_content_host) # list hosts result = HostCollection.hosts({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_system['name'].lower(), result[0]['name']) # List all host collections within organization result = HostCollection.list( {'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by name result = HostCollection.list({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], new_host_col['id']) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': new_system['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], new_host_col['name']) # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id'] })['total-hosts'] HostCollection.remove_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(no_of_content_host, result['total-hosts']) # update new_name = valid_data_list()[0] new_desc = valid_data_list()[0] HostCollection.update({ 'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['name'], new_name) self.assertEqual(result['description'], new_desc) # delete HostCollection.delete({'id': new_host_col['id']}) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})