Esempio n. 1
0
    def test_untar_challenge_data_package_no_tarfile(self):

        params = D3RParameters()
        task = ExternalDataSubmissionTask('/foo', 'name',
                                          '/remote/hello.tar.gz', params)
        try:
            task._untar_challenge_data_package('hello')
            self.fail('Expected IOError')
        except IOError:
            pass
Esempio n. 2
0
 def test_untar_challenge_data_package_dotdot_tarfile(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         task = ExternalDataSubmissionTask(temp_dir, 'hello',
                                           'hi', params)
         task.create_dir()
         self.create_bad_tarfile_dotdot_path(task.get_dir(),
                                             'hello')
         c = task._untar_challenge_data_package('hello.tar.gz')
         self.assertEqual(c, 'hello')
         self.assertEqual(task.get_email_log(), 'Skipping, found .. in '
                                                'path: hello/5juw/apo-'
                                                '5juw_2eb2_..docked.mol\n'
                                                'Ignoring non dir/file '
                                                'entry in tar 5juw/hello\n')
         candidate = os.path.join(task.get_dir(), 'hello', '5juw')
         self.assertTrue(os.path.isdir(candidate))
         mypdb = os.path.join(candidate,
                              'apo-5juw_2eb2_docked.pdb')
         mymol = os.path.join(candidate,
                              'apo-5juw_2eb2.._docked.mol')
         self.assertTrue(os.path.isfile(mypdb))
         self.assertFalse(os.path.isfile(mymol))
     finally:
         shutil.rmtree(temp_dir)
Esempio n. 3
0
 def test_untar_challenge_data_package_good_tarfile(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         task = ExternalDataSubmissionTask(temp_dir, 'hello', 'hi', params)
         task.create_dir()
         self.create_good_tarfile(task.get_dir(), 'hello')
         c = task._untar_challenge_data_package('hello.tar.gz')
         self.assertEqual(c, 'hello')
         self.assertEqual(task.get_email_log(), None)
         candidate = os.path.join(task.get_dir(), 'hello', '5juw')
         self.assertTrue(os.path.isdir(candidate))
         mypdb = os.path.join(candidate, 'apo-5juw_2eb2_docked.pdb')
         mymol = os.path.join(candidate, 'apo-5juw_2eb2_docked.mol')
         self.assertTrue(os.path.isfile(mypdb))
         self.assertTrue(os.path.isfile(mymol))
     finally:
         shutil.rmtree(temp_dir)
Esempio n. 4
0
    def test_untar_challenge_data_package_wrong_prefix(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            task = ExternalDataSubmissionTask(temp_dir, 'yo', 'hi', params)
            task.create_dir()
            tfile = self.create_good_tarfile(task.get_dir(), 'yo')
            shutil.move(tfile, os.path.join(task.get_dir(), 'byte.tar.gz'))
            c = task._untar_challenge_data_package('byte.tar.gz')
            self.assertEqual(c, 'byte')

            candidate = os.path.join(task.get_dir(), 'hello', '5juw')
            self.assertFalse(os.path.isdir(candidate))
            mypdb = os.path.join(candidate, 'apo-5juw_2eb2_docked.pdb')
            mymol = os.path.join(candidate, 'apo-5juw_2eb2.._docked.mol')
            self.assertFalse(os.path.isfile(mypdb))
            self.assertFalse(os.path.isfile(mymol))
        finally:
            shutil.rmtree(temp_dir)