def test_update_status_can_be_roundtripped_40214(self): complete_job_xml = pkg_resources.resource_string( 'bkr.inttest', 'job_40214.xml') xmljob = XmlJob(xmltramp.parse(complete_job_xml)) data_setup.create_tasks(xmljob) session.flush() # Import the job xml job = self.controller.process_xmljob(xmljob, self.user) session.flush() # Mark job waiting data_setup.mark_job_waiting(job) session.flush() # watchdog's should exist self.assertNotEqual(len(watchdogs_for_job(job)), 0) # Play back the original jobs results and status data_setup.playback_job_results(job, xmljob) session.flush() # Verify that the original status and results match self.assertEquals(TaskStatus.from_string(xmljob.wrappedEl('status')), job.status) self.assertEquals(TaskResult.from_string(xmljob.wrappedEl('result')), job.result) for i, recipeset in enumerate(xmljob.iter_recipeSets()): for j, recipe in enumerate(recipeset.iter_recipes()): self.assertEquals( TaskStatus.from_string(recipe.wrappedEl('status')), job.recipesets[i].recipes[j].status) self.assertEquals( TaskResult.from_string(recipe.wrappedEl('result')), job.recipesets[i].recipes[j].result) for k, task in enumerate(recipe.iter_tasks()): self.assertEquals( TaskStatus.from_string(task.status), job.recipesets[i].recipes[j].tasks[k].status) self.assertEquals( TaskResult.from_string(task.result), job.recipesets[i].recipes[j].tasks[k].result) # No watchdog's should exist when the job is complete self.assertEquals(len(watchdogs_for_job(job)), 0)
def test_update_status_can_be_roundtripped_40214(self): complete_job_xml = pkg_resources.resource_string('bkr.inttest', 'job_40214.xml') xmljob = XmlJob(xmltramp.parse(complete_job_xml)) data_setup.create_tasks(xmljob) session.flush() # Import the job xml job = self.controller.process_xmljob(xmljob, self.user) session.flush() # Mark job waiting data_setup.mark_job_waiting(job) session.flush() # watchdog's should exist self.assertNotEqual(len(watchdogs_for_job(job)), 0) # Play back the original jobs results and status data_setup.playback_job_results(job, xmljob) session.flush() # Verify that the original status and results match self.assertEquals(TaskStatus.from_string(xmljob.wrappedEl('status')), job.status) self.assertEquals(TaskResult.from_string(xmljob.wrappedEl('result')), job.result) for i, recipeset in enumerate(xmljob.iter_recipeSets()): for j, recipe in enumerate(recipeset.iter_recipes()): self.assertEquals(TaskStatus.from_string(recipe.wrappedEl('status')), job.recipesets[i].recipes[j].status) self.assertEquals(TaskResult.from_string(recipe.wrappedEl('result')), job.recipesets[i].recipes[j].result) for k, task in enumerate(recipe.iter_tasks()): self.assertEquals(TaskStatus.from_string(task.status), job.recipesets[i].recipes[j].tasks[k].status) self.assertEquals(TaskResult.from_string(task.result), job.recipesets[i].recipes[j].tasks[k].result) # No watchdog's should exist when the job is complete self.assertEquals(len(watchdogs_for_job(job)), 0)
def test_update_status_can_be_roundtripped_40214(self): complete_job_xml = pkg_resources.resource_string("bkr.inttest", "job_40214.xml") xmljob = lxml.etree.fromstring(complete_job_xml) data_setup.create_tasks(xmljob) session.flush() # Import the job xml job = self.controller.process_xmljob(xmljob, self.user) session.flush() # Mark job waiting data_setup.mark_job_waiting(job) session.flush() # watchdog's should exist self.assertNotEqual(len(watchdogs_for_job(job)), 0) # Play back the original jobs results and status data_setup.playback_job_results(job, xmljob) session.flush() # Verify that the original status and results match self.assertEquals(TaskStatus.from_string(xmljob.get("status")), job.status) self.assertEquals(TaskResult.from_string(xmljob.get("result")), job.result) for i, recipeset in enumerate(xmljob.xpath("recipeSet")): for j, recipe in enumerate(recipeset.xpath("recipes")): self.assertEquals(TaskStatus.from_string(recipe.get("status")), job.recipesets[i].recipes[j].status) self.assertEquals(TaskResult.from_string(recipe.get("result")), job.recipesets[i].recipes[j].result) for k, task in enumerate(recipe.xpath("task")): self.assertEquals( TaskStatus.from_string(task.get("status")), job.recipesets[i].recipes[j].tasks[k].status ) self.assertEquals( TaskResult.from_string(task.get("result")), job.recipesets[i].recipes[j].tasks[k].result ) # No watchdog's should exist when the job is complete self.assertEquals(len(watchdogs_for_job(job)), 0)