def test_on_created_run(self, log, event):
     with patch('porerefiner.fsevents.Run') as run:
         self.assertGreater(len(event.src_path.parts), 2)
         note(event.src_path)
         run.get_or_create.return_value = (run, True)
         _run(Handler(event.src_path.parts[0]).on_created(event))
         run.save.assert_called()
 def test_on_created_file(self, event):
     with patch('porerefiner.fsevents.Run') as run:
         with patch('porerefiner.fsevents.File') as file:
             self.assertGreater(len(event.src_path.parts), 3)
             note(event.src_path)
             run.get_or_create.return_value = (run, False)
             _run(Handler(event.src_path.parts[0]).on_created(event))
             file.create.assert_called()
 def test_on_deleted_file(self, event):
     _run(Handler(event.src_path.parts[0]).on_created(event))
     fi = File.get_or_none(File.path == r(event.src_path))
     self.assertIsNotNone(fi)  # check test setup correctly
     fi.tag("TEST")
     fi.ttag("TEST", "TEST", "TEST")
     _run(Handler(event.src_path.parts[0]).on_deleted(event))
     fi = File.get_or_none(File.path == r(event.src_path))
     self.assertIsNone(fi)  # should be deleted
Ejemplo n.º 4
0
 def test_tags_arent_deleted_on_run_end(self, tag, run):
     run.save()
     ta = run.tag(tag)
     tta = run.ttag(tag, tag, tag)
     _run(fsevents.end_run(run))
     fin = models.Tag.get(name="finished")
     self.assertIn(ta, run.tags)
     self.assertIn(fin, run.tags)
     self.assertIn(tta, run.tags)
Ejemplo n.º 5
0
 def test_tags_arent_deleted_on_file_deletion(self, tag, file_event, run):
     file, event = file_event
     assert file.path == event.src_path
     file.save()
     models.File.get(file.id)
     file.tag(tag)
     run.save()
     tag = run.tag(tag)
     self.assertEqual(len(list(run.tags)), 1)
     self.assertEqual(len(list(file.tags)), 1)
     _run(Handler(event.src_path.parts[0]).on_deleted(event))
     self.assertFalse(
         models.File.get_or_none(models.File.path == event.src_path)
     )  # check file record is gone
     self.assertEqual(len(list(run.tags)), 1)
     self.assertIn(tag, run.tags)
 def test_end_file(self, file=Mock()):
     with NamedTemporaryFile() as tfile:
         file.path = Path(tfile.name)
         _run(end_file(file))
         file.save.assert_called()
 def test_on_created_flowcell(self, event, reg):
     # flow.get_or_create.return_value = (flow, True)
     _run(Handler(event.src_path.parent).on_created(event))
     reg.assert_called()
Ejemplo n.º 8
0
 def test_submit(self, job_rec, job_code, run):
     run.save()
     job_rec.run = run
     job_rec.save()
     _run(job_code.submitter._submit(job_rec))