Example #1
0
 def test_touch(self):
     path = base.random_alpha_num_word(16)
     try:
         self.assertFalse(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
     finally:
         base.remove(path)
Example #2
0
 def test_touch(self):
     path = base.random_alpha_num_word(16)
     try:
         self.assertFalse(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
     finally:
         base.remove(path)
Example #3
0
    def testPersistentTaskRunCreateFile(self):
        """Running a persistent task with success creates the output file."""

        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.SUCCESS

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        try:
            task = PTask(output_file_path=file_path, task_id="task", workflow=flow)
            flow.build()
            self.assertFalse(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)
Example #4
0
    def testPersistentTaskNoRunIfFile(self):
        """Persistent task does not run if output file already exists."""

        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.FAILURE

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        base.touch(file_path)
        try:
            task = PTask(output_file_path=file_path, task_id="task", workflow=flow)
            flow.build()
            self.assertTrue(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)
Example #5
0
    def testPersistentTaskRunCreateFile(self):
        """Running a persistent task with success creates the output file."""
        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.SUCCESS

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        try:
            task = PTask(
                output_file_path=file_path,
                task_id='task',
                workflow=flow,
            )
            flow.build()
            self.assertFalse(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)
Example #6
0
    def testPersistentTaskNoRunIfFile(self):
        """Persistent task does not run if output file already exists."""
        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.FAILURE

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        base.touch(file_path)
        try:
            task = PTask(
                output_file_path=file_path,
                task_id='task',
                workflow=flow,
            )
            flow.build()
            self.assertTrue(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)