Exemplo n.º 1
0
    def test_run_fail(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            pkg = '/remote/celpp1_2017_dockedresults_yo.tar.gz'
            task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params)
            mockft = D3RParameters()
            mockft.connect = Mock(side_effect=IOError('error'))
            mockft.download_file = Mock(return_value=True)
            mockft.disconnect = Mock(return_value=None)
            task.set_file_transfer(mockft)
            task.run()
            self.assertEqual(
                task.get_error(), 'Caught exception Unable to '
                'download celpp1_2017_docked'
                'results_yo.tar.gz')
            self.assertEqual(
                task.get_email_log(), 'Try # 1 of 3 to download '
                'celpp1_2017_dockedresults'
                '_yo.tar.gz\nTry # 2 of 3 '
                'to download celpp1_2017_d'
                'ockedresults_yo.tar.gz\n'
                'Try # 3 of 3 to download '
                'celpp1_2017_dockedresults'
                '_yo.tar.gz\n')

        finally:
            shutil.rmtree(temp_dir)
Exemplo n.º 2
0
    def test_externaltask_can_run(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            task = ExternalDataSubmissionTask(temp_dir, 'name', '/remote',
                                              params)
            self.assertTrue(task.can_run())

            task.create_dir()
            self.assertFalse(task.can_run())
            self.assertEqual(task.get_error(), 'stage.6.name.extsubmission '
                                               'already exists and status is '
                                               'unknown')
            open(os.path.join(task.get_dir(),
                              D3RTask.COMPLETE_FILE), 'a').close()

            self.assertFalse(task.can_run())
            self.assertEqual(task.get_error(), None)
        finally:
            shutil.rmtree(temp_dir)
Exemplo n.º 3
0
 def test_run_unable_to_run_cause_can_run_is_false(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         pkg = '/remote/celpp2_3.tar.gz'
         task = ExternalDataSubmissionTask(temp_dir, 'yo',
                                           pkg, params)
         task.create_dir()
         task.run()
         self.assertEqual(task.get_email_log(), None)
         self.assertEqual(task.get_error(), 'stage.6.yo.extsubmission '
                                            'already exists and status '
                                            'is unknown')
     finally:
         shutil.rmtree(temp_dir)
Exemplo n.º 4
0
 def test_runtask_success(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         pkg = '/remote/celpp1_2017_dockedresults_yo.tar.gz'
         task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params)
         mockft = D3RParameters()
         mockft.connect = Mock(return_value=None)
         mockft.download_file = Mock(return_value=True)
         mockft.disconnect = Mock(return_value=None)
         task.set_file_transfer(mockft)
         task.create_dir()
         self.create_good_tarfile(task.get_dir(),
                                  'celpp1_2017_dockedresults_yo')
         task._runtask()
         self.assertEqual(task.get_error(), None)
         self.assertEqual(task.get_email_log(), '')
     finally:
         shutil.rmtree(temp_dir)