def test_positive_remove_sync_plan_by_id(self): """Check if a sync plan can be removed from a product :id: 0df2005c-158a-48cb-8a16-9a63923699fc :expectedresults: Product has sync plan :CaseLevel: Integration """ product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['sync-plan-id'], sync_plan['id']) 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)
def test_positive_remove_sync_plan_by_id(self): """Check if a sync plan can be removed from a product @id: 0df2005c-158a-48cb-8a16-9a63923699fc @Assert: Product has sync plan @CaseLevel: Integration """ product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['sync-plan-id'], sync_plan['id']) 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)
def test_remove_syncplan_1(self): """@Test: Check if product can be assigned a syncplan @Feature: Product @Assert: Product has syncplan """ product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['sync-plan-id'], sync_plan['id']) 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)
def test_remove_syncplan_1(self): """@Test: Check if product can be assigned a syncplan @Feature: Product @Assert: Product has syncplan """ product = make_product({u"organization-id": self.org["id"]}) sync_plan = make_sync_plan({"organization-id": self.org["id"]}) Product.set_sync_plan({"id": product["id"], "sync-plan-id": sync_plan["id"]}) product = Product.info({"id": product["id"], "organization-id": self.org["id"]}) self.assertEqual(product["sync-plan-id"], sync_plan["id"]) 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)
def test_remove_syncplan_1(self): """@Test: Check if product can be assigned a syncplan @Feature: Product @Assert: Product has syncplan @BZ: 1121136 """ try: new_product = make_product( { u'organization-id': self.org['id'] } ) s = make_sync_plan({'organization-id': self.org['id']}) s_result = Product.set_sync_plan( { 'sync-plan-id': s['id'], 'id': new_product['id'] } ) except CLIFactoryError as err: self.fail(err) self.assertEqual( s_result.stderr, [], "Running set_sync_plan should cause no errors.") i_result = Product.info({'id': new_product['id'], 'organization-id': self.org['id']}) self.assertEqual( i_result.stderr, [], "Running product info should cause no errors.") self.assertEqual( i_result.stdout['sync-plan-id'], s['id'], "Info should have consistent sync ids.") r_result = Product.remove_sync_plan( { 'sync-plan-id': s['id'], 'id': new_product['id'] } ) self.assertEqual( r_result.stderr, [], "Running product remove_sync_plan should cause no errors.") i_result = Product.info({'id': new_product['id'], 'organization-id': self.org['id']}) self.assertEqual( i_result.stderr, [], "Running product info should cause no errors.") self.assertEqual( len(i_result.stdout['sync-plan-id']), 0, "Info should have no sync ids.")
def test_remove_syncplan_1(self): """@Test: Check if product can be assigned a syncplan @Feature: Product @Assert: Product has syncplan """ try: product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) result = Product.set_sync_plan({ 'sync-plan-id': sync_plan['id'], 'id': product['id'], }) except CLIFactoryError as err: self.fail(err) self.assertEqual( result.stderr, [], 'Running set_sync_plan should cause no errors.' ) result = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual( result.stderr, [], 'Running product info should cause no errors.' ) self.assertEqual( result.stdout['sync-plan-id'], sync_plan['id'], 'Info should have consistent sync ids.' ) r_result = Product.remove_sync_plan({ 'id': product['id'], }) self.assertEqual( r_result.stderr, [], 'Running product remove_sync_plan should cause no errors.' ) result = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual( result.stderr, [], 'Running product info should cause no errors.' ) self.assertEqual( len(result.stdout['sync-plan-id']), 0, 'Info should have no sync id.' )
def test_positive_remove_sync_plan_by_id(self): """@Test: Check if a sync plan can be removed from a product @Feature: Product @Assert: Product has sync plan """ product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['sync-plan-id'], sync_plan['id']) 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)
def test_positive_remove_sync_plan_by_id(self): """Check if a sync plan can be removed from a product @Feature: Product @Assert: Product has sync plan """ product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['sync-plan-id'], sync_plan['id']) 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)
def test_remove_syncplan_1(self): """@Test: Check if product can be assigned a syncplan @Feature: Product @Assert: Product has syncplan """ try: product = make_product({u'organization-id': self.org['id']}) sync_plan = make_sync_plan({'organization-id': self.org['id']}) except CLIFactoryError as err: self.fail(err) result = Product.set_sync_plan({ 'sync-plan-id': sync_plan['id'], 'id': product['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertEqual(result.stdout['sync-plan-id'], sync_plan['id']) result = Product.remove_sync_plan({ 'id': product['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertEqual(len(result.stdout['sync-plan-id']), 0)
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})