def test_positive_delete_1(self): """@Test: Check if product can be deleted @Feature: Product @Assert: Product is deleted """ new_product = make_product({u"organization-id": self.org["id"]}) Product.delete({u"id": new_product["id"]}) with self.assertRaises(CLIReturnCodeError): Product.info({u"id": new_product["id"], u"organization-id": self.org["id"]}) if bz_bug_is_open(1219490): for _ in range(5): time.sleep(5) Product.info({u"id": new_product["id"], u"organization-id": self.org["id"]})
def test_positive_delete_1(self): """@Test: Check if product can be deleted @Feature: Product @Assert: Product is deleted """ new_product = make_product({ u'organization-id': self.org['id'] }) # Delete it result = Product.delete({u'id': new_product['id']}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Fetch it result = Product.info({ u'id': new_product['id'], u'organization-id': self.org['id'], }) if bz_bug_is_open(1219490): for _ in range(5): if result.return_code == 0: time.sleep(5) result = Product.info({ u'id': new_product['id'], u'organization-id': self.org['id'], }) else: break self.assertNotEqual(result.return_code, 0) self.assertGreater(len(result.stderr), 0)
def test_positive_delete_by_id(self): """Check if product can be deleted @id: 21bb8373-96d1-402c-973c-cf70d4b8244e @Assert: Product is deleted """ new_product = make_product({u'organization-id': self.org['id']}) Product.delete({u'id': new_product['id']}) with self.assertRaises(CLIReturnCodeError): Product.info({ u'id': new_product['id'], u'organization-id': self.org['id'], }) if bz_bug_is_open(1219490): for _ in range(5): time.sleep(5) Product.info({ u'id': new_product['id'], u'organization-id': self.org['id'], })
def test_positive_delete_1(self, test_name): """@Test: Check if product can be deleted @Feature: Product @Assert: Product is deleted @BZ: 1096320 """ new_product = make_product( { u'name': test_name['name'], u'organization-id': self.org['id'] } ) # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertEqual( result.return_code, 0, "Product was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertEqual( result.stdout['name'], new_product['name'], "Names don't match") self.assertGreater( len(result.stdout['label']), 0, "Label not automatically created" ) # Delete it result = Product.delete({u'id': new_product['id']}) self.assertEqual( result.return_code, 0, "Product was not deleted") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertNotEqual( result.return_code, 0, "Product should not be found") self.assertGreater( len(result.stderr), 0, "Error was expected")
def test_positive_delete_1(self, test_name): """@Test: Check if product can be deleted @Feature: Product @Assert: Product is deleted """ new_product = make_product( { u'name': test_name['name'], u'organization-id': self.org['id'] } ) # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertEqual( result.return_code, 0, "Product was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertEqual( result.stdout['name'], new_product['name'], "Names don't match") self.assertGreater( len(result.stdout['label']), 0, "Label not automatically created" ) # Delete it result = Product.delete({u'id': new_product['id']}) self.assertEqual( result.return_code, 0, "Product was not deleted") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertNotEqual( result.return_code, 0, "Product should not be found") self.assertGreater( len(result.stderr), 0, "Error was expected")
def test_positive_CRUD(self): """Check if product can be created, updated, synchronized and deleted :id: 9d7b5ec8-59d0-4371-b5d2-d43145e4e2db :expectedresults: Product is created, updated, synchronized and deleted :BZ: 1422552 :CaseImportance: Critical """ desc = list(valid_data_list().values())[0] gpg_key = make_gpg_key({'organization-id': self.org['id']}) name = list(valid_data_list().values())[0] label = valid_labels_list()[0] sync_plan = make_sync_plan({'organization-id': self.org['id']}) product = make_product({ 'description': desc, 'gpg-key-id': gpg_key['id'], 'label': label, 'name': name, 'organization-id': self.org['id'], 'sync-plan-id': sync_plan['id'], }) self.assertEqual(product['name'], name) self.assertGreater(len(product['label']), 0) self.assertEqual(product['label'], label) self.assertEqual(product['description'], desc) self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id']) self.assertEqual(product['sync-plan-id'], sync_plan['id']) # update desc = list(valid_data_list().values())[0] new_gpg_key = make_gpg_key({'organization-id': self.org['id']}) new_sync_plan = make_sync_plan({'organization-id': self.org['id']}) new_prod_name = gen_string('alpha', 8) Product.update({ 'description': desc, 'id': product['id'], 'gpg-key-id': new_gpg_key['id'], 'sync-plan-id': new_sync_plan['id'], 'name': new_prod_name, }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'] }) self.assertEqual(product['name'], new_prod_name) self.assertEqual(product['description'], desc) self.assertEqual(product['gpg']['gpg-key-id'], new_gpg_key['id']) self.assertNotEqual(product['gpg']['gpg-key-id'], gpg_key['id']) self.assertEqual(product['sync-plan-id'], new_sync_plan['id']) self.assertNotEqual(product['sync-plan-id'], sync_plan['id']) # synchronize repo = make_repository({ 'product-id': product['id'], 'url': FAKE_0_YUM_REPO }) Product.synchronize({ 'id': product['id'], 'organization-id': self.org['id'] }) packages = Package.list({'product-id': product['id']}) repo = Repository.info({'id': repo['id']}) self.assertEqual(int(repo['content-counts']['packages']), len(packages)) self.assertEqual(len(packages), FAKE_0_YUM_REPO_PACKAGES_COUNT) # delete Product.remove_sync_plan({'id': product['id']}) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'] }) self.assertEqual(len(product['sync-plan-id']), 0) Product.delete({'id': product['id']}) wait_for_tasks( search_query='label = Actions::Katello::Product::Destroy' ' and resource_id = {}'.format(product['id']), max_tries=10, ) with self.assertRaises(CLIReturnCodeError): Product.info({ 'id': product['id'], 'organization-id': self.org['id'] })
def test_positive_CRUD(module_org): """Check if product can be created, updated, synchronized and deleted :id: 9d7b5ec8-59d0-4371-b5d2-d43145e4e2db :expectedresults: Product is created, updated, synchronized and deleted :BZ: 1422552 :CaseImportance: Critical """ desc = list(valid_data_list().values())[0] gpg_key = make_content_credential({'organization-id': module_org.id}) name = list(valid_data_list().values())[0] label = valid_labels_list()[0] sync_plan = make_sync_plan({'organization-id': module_org.id}) product = make_product( { 'description': desc, 'gpg-key-id': gpg_key['id'], 'label': label, 'name': name, 'organization-id': module_org.id, 'sync-plan-id': sync_plan['id'], }, ) assert product['name'] == name assert len(product['label']) > 0 assert product['label'] == label assert product['description'] == desc assert product['gpg']['gpg-key-id'] == gpg_key['id'] assert product['sync-plan-id'] == sync_plan['id'] # update desc = list(valid_data_list().values())[0] new_gpg_key = make_content_credential({'organization-id': module_org.id}) new_sync_plan = make_sync_plan({'organization-id': module_org.id}) new_prod_name = gen_string('alpha', 8) Product.update( { 'description': desc, 'id': product['id'], 'gpg-key-id': new_gpg_key['id'], 'sync-plan-id': new_sync_plan['id'], 'name': new_prod_name, } ) product = Product.info({'id': product['id'], 'organization-id': module_org.id}) assert product['name'] == new_prod_name assert product['description'] == desc assert product['gpg']['gpg-key-id'] == new_gpg_key['id'] assert product['gpg']['gpg-key-id'] != gpg_key['id'] assert product['sync-plan-id'] == new_sync_plan['id'] assert product['sync-plan-id'] != sync_plan['id'] # synchronize repo = make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], 'url': settings.repos.yum_0.url, }, ) Product.synchronize({'id': product['id'], 'organization-id': module_org.id}) packages = Package.list({'product-id': product['id']}) repo = Repository.info({'id': repo['id']}) assert int(repo['content-counts']['packages']) == len(packages) assert len(packages) == FAKE_0_YUM_REPO_PACKAGES_COUNT # delete Product.remove_sync_plan({'id': product['id']}) product = Product.info({'id': product['id'], 'organization-id': module_org.id}) assert len(product['sync-plan-id']) == 0 Product.delete({'id': product['id']}) wait_for_tasks( search_query="label = Actions::Katello::Product::Destroy" f" and resource_id = {product['id']}", max_tries=10, ) with pytest.raises(CLIReturnCodeError): Product.info({'id': product['id'], 'organization-id': module_org.id})