def test_cloning_recipeset_from_job_with_product(self): with session.begin(): job = data_setup.create_job() job.retention_tag = RetentionTag.list_by_requires_product()[0] job.product = Product(u'product_name') b = self.browser login(b) b.get(get_server_base() + 'jobs/clone?job_id=%s' % job.id) cloned_from_job = b.find_element_by_xpath('//textarea[@name="textxml"]').text b.get(get_server_base() + 'jobs/clone?recipeset_id=%s' % job.recipesets[0].id) cloned_from_rs = b.find_element_by_xpath('//textarea[@name="textxml"]').text self.assertEqual(cloned_from_job,cloned_from_rs)
def check_product_job(cls, job, product): """ performs logic needed to determine if changing a retention_tag is valid, returns an error fit for displaying in widget """ retentiontag = job.retention_tag if not retentiontag.requires_product() and \ product != ProductWidget.product_deselected: return{'success': False, 'msg': 'Current retention tag does not support a product', 'vars': {cls._needs_tag: 1, 'VALID_TAGS': [[tag.id,tag.tag] for tag in \ RetentionTag.list_by_requires_product()]}} if retentiontag.requires_product() and \ product == ProductWidget.product_deselected: return{'success': False, 'msg': 'Current retention tag requires a product', 'vars': {cls._needs_tag: 1, 'VALID_TAGS': [[tag.id,tag.tag] for tag in \ RetentionTag.list_by_requires_product(False)]}} return {'success': True}
def update_product(cls, job, product): """ performs logic needed to determine if changing a retention_tag is valid, returns an error fit for displaying in widget """ retentiontag = job.retention_tag if not retentiontag.requires_product() and \ product != None: return{'success': False, 'msg': 'Current retention tag does not support a product', 'vars': {cls._needs_tag: 1, 'VALID_TAGS': [[tag.id,tag.tag] for tag in \ RetentionTag.list_by_requires_product()]}} if retentiontag.requires_product() and \ product == None: return{'success': False, 'msg': 'Current retention tag requires a product', 'vars': {cls._needs_tag: 1, 'VALID_TAGS': [[tag.id,tag.tag] for tag in \ RetentionTag.list_by_requires_product(False)]}} job.product = product return {'success': True}