def test_positive_product_sync_state(module_org): """hammer product info shows correct sync state. :id: 58af6239-85d7-4b8b-bd2d-ab4cd4f29840 :BZ: 1803207,1999541 :customerscenario: true :Steps: 1. Sync a custom repository that fails. 2. Run `hammer product info --product-id <id>`. 3. Successfully sync another repository under the same product. 4. Run `hammer product info --product-id <id>` again. :expectedresults: hammer should show 'Sync Incomplete' in both cases. """ product = make_product({'organization-id': module_org.id}) repo_a1 = make_repository({ 'organization-id': module_org.id, 'product-id': product['id'], 'name': gen_string('alpha'), 'url': f'{gen_url(scheme="https")}:{gen_integer(min_value=10, max_value=9999)}', }) with pytest.raises(CLIReturnCodeError): Repository.synchronize({'id': repo_a1['id']}) product_info = Product.info({ 'id': product['id'], 'organization-id': module_org.id }) product_list = Product.list({'organization-id': module_org.id}) assert product_info['sync-state-(last)'] in [ p.get('sync-state') for p in product_list ] repo_a2 = make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], 'name': gen_string('alpha'), 'url': settings.repos.yum_0.url, }, ) Repository.synchronize({'id': repo_a2['id']}) product_info = Product.info({ 'id': product['id'], 'organization-id': module_org.id }) product_list = Product.list({'organization-id': module_org.id}) assert product_info['sync-state-(last)'] in [ p.get('sync-state') for p in product_list ]
def test_product_list_with_default_settings(module_org, default_sat): """Listing product of an organization apart from default organization using hammer does not return output if a defaults settings are applied on org. :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef :BZ: 1745575 :customerscenario: true :expectedresults: product/reporsitory list should work as expected. """ org_id = str(module_org.id) default_product_name = gen_string('alpha') non_default_product_name = gen_string('alpha') non_default_org = make_org() default_product = make_product({ 'name': default_product_name, 'organization-id': org_id }) non_default_product = make_product({ 'name': non_default_product_name, 'organization-id': non_default_org['id'] }) for product in default_product, non_default_product: make_repository( { 'organization-id': org_id, 'product-id': product['id'], 'url': settings.repos.yum_0.url, }, ) Defaults.add({'param-name': 'organization_id', 'param-value': org_id}) result = default_sat.cli.Defaults.list(per_page=False) assert any([ res['value'] == org_id for res in result if res['parameter'] == 'organization_id' ]) try: # Verify --organization-id is not required to pass if defaults are set result = default_sat.cli.Product.list() assert any([res['name'] == default_product_name for res in result]) result = default_sat.cli.Repository.list() assert any([res['product'] == default_product_name for res in result]) # verify that defaults setting should not affect other entities product_list = Product.list({'organization-id': non_default_org['id']}) assert non_default_product_name == product_list[0]['name'] repository_list = Repository.list( {'organization-id': non_default_org['id']}) assert non_default_product_name == repository_list[0]['product'] finally: Defaults.delete({'param-name': 'organization_id'}) result = default_sat.cli.Defaults.list(per_page=False) assert not [ res for res in result if res['parameter'] == 'organization_id' ]
def test_product_list_with_default_settings(self): """Listing product of an organization apart from default organization using hammer does not return output if a defaults settings are applied on org. :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef :BZ: 1745575 :expectedresults: product/reporsitory list should work as expected. """ default_product_name = gen_string('alpha') non_default_product_name = gen_string('alpha') default_org = self.org non_default_org = make_org() default_product = make_product({ 'name': default_product_name, 'organization-id': default_org['id'] }) non_default_product = make_product({ 'name': non_default_product_name, 'organization-id': non_default_org['id'] }) for product in (default_product, non_default_product): make_repository({ 'product-id': product['id'], 'url': FAKE_0_YUM_REPO }) Defaults.add({ 'param-name': 'organization_id', 'param-value': default_org['id'] }) result = ssh.command('hammer defaults list') self.assertTrue(default_org['id'] in "".join(result.stdout)) try: # Verify --organization-id is not required to pass if defaults are set result = ssh.command('hammer product list') self.assertTrue(default_product_name in "".join(result.stdout)) result = ssh.command('hammer repository list') self.assertTrue(default_product_name in "".join(result.stdout)) # verify that defaults setting should not affect other entities product_list = Product.list( {'organization-id': non_default_org['id']}) self.assertEquals(non_default_product_name, product_list[0]['name']) repository_list = Repository.list( {'organization-id': non_default_org['id']}) self.assertEquals(non_default_product_name, repository_list[0]['product']) finally: Defaults.delete({'param-name': 'organization_id'}) result = ssh.command('hammer defaults list') self.assertTrue(default_org['id'] not in "".join(result.stdout))
def _get_production_id(self): """Get organization id""" result = Product.list({'organization-id': self.org_id}, per_page=False) if result.return_code != 0: self.logger.error('Fail to list default products.') raise RuntimeError('Invalid product id. Stop!') for item in result.stdout: if item['name'] == u'Red Hat Enterprise Linux Server': return item['id']
def test_product_list_with_default_settings(module_org): """Listing product of an organization apart from default organization using hammer does not return output if a defaults settings are applied on org. :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef :BZ: 1745575 :customerscenario: true :expectedresults: product/reporsitory list should work as expected. """ org_id = str(module_org.id) default_product_name = gen_string('alpha') non_default_product_name = gen_string('alpha') non_default_org = make_org() default_product = make_product({ 'name': default_product_name, 'organization-id': org_id }) non_default_product = make_product({ 'name': non_default_product_name, 'organization-id': non_default_org['id'] }) for product in default_product, non_default_product: make_repository( { 'organization-id': org_id, 'product-id': product['id'], 'url': FAKE_0_YUM_REPO, }, ) Defaults.add({'param-name': 'organization_id', 'param-value': org_id}) result = ssh.command('hammer defaults list') assert org_id in "".join(result.stdout) try: # Verify --organization-id is not required to pass if defaults are set result = ssh.command('hammer product list') assert default_product_name in "".join(result.stdout) result = ssh.command('hammer repository list') assert default_product_name in "".join(result.stdout) # verify that defaults setting should not affect other entities product_list = Product.list({'organization-id': non_default_org['id']}) assert non_default_product_name == product_list[0]['name'] repository_list = Repository.list( {'organization-id': non_default_org['id']}) assert non_default_product_name == repository_list[0]['product'] finally: Defaults.delete({'param-name': 'organization_id'}) result = ssh.command('hammer defaults list') assert org_id not in "".join(result.stdout)
def _get_production_id(self): """Get available product id after uploading manifest""" try: result = Product.list({'organization-id': self.org_id}, per_page=False) except CLIReturnCodeError: self.logger.error('Fail to list default products.') raise RuntimeError('Invalid product id. Stop!') for item in result: if item['name'] == u'Red Hat Enterprise Linux Server': return item['id']
def _get_production_id(self): """Get available product id after uploading manifest""" try: result = Product.list( {'organization-id': self.org_id}, per_page=False ) except CLIReturnCodeError: self.logger.error('Fail to list default products.') raise RuntimeError('Invalid product id. Stop!') for item in result: if item['name'] == u'Red Hat Enterprise Linux Server': return item['id']