Ejemplo n.º 1
0
 def test_get_external_data_submissions_two_extdatasubmission(self):
     temp_dir = tempfile.mkdtemp()
     try:
         year = os.path.join(temp_dir, '2017')
         week = os.path.join(year, 'dataset.week.13')
         os.makedirs(week)
         dr = ExternalDataSubmissionFactory.DOCKEDRESULTS
         params = D3RParameters()
         fac = ExternalDataSubmissionFactory(week, params)
         mockft = D3RParameters()
         mockft.connect = Mock()
         mockft.delete_file = Mock(return_value=True)
         mockft.get_remote_challenge_dir = Mock(return_value='/chall')
         mockft.get_remote_submission_dir = Mock(return_value='/remote')
         mockft.list_dirs = Mock(return_value=['yo', 'yuck'])
         mockft.list_files = Mock(return_value=['hi',
                                                'celpp_week13_2017' + dr +
                                                'yo.tar.gz',
                                                'celpp_week13_2017' + dr +
                                                'yuck.tar.gz'])
         fac.set_file_transfer(mockft)
         tlist = fac.get_external_data_submissions()
         self.assertEqual(len(tlist), 2)
         self.assertEqual(tlist[0].get_name(), 'yo.extsubmission')
         self.assertEqual(tlist[0].get_remote_challenge_data_package(),
                          '/remote/yo/celpp_week13_2017' + dr + 'yo.tar.gz')
         self.assertEqual(tlist[1].get_name(), 'yuck.extsubmission')
         self.assertEqual(tlist[1].get_remote_challenge_data_package(),
                          '/remote/yuck/celpp_week13_2017' + dr +
                          'yuck.tar.gz')
         mockft.list_dirs.assert_called_with('/remote')
         mockft.list_files.assert_called_with('/remote/yuck')
         mockft.delete_file.assert_called_with('/chall/latest.txt')
     finally:
         shutil.rmtree(temp_dir)
Ejemplo n.º 2
0
 def test_get_external_data_submissions_no_chall_packages(self):
     temp_dir = tempfile.mkdtemp()
     try:
         year = os.path.join(temp_dir, '2016')
         week = os.path.join(year, 'dataset.week.13')
         os.makedirs(week)
         dr = ExternalDataSubmissionFactory.DOCKEDRESULTS
         params = D3RParameters()
         fac = ExternalDataSubmissionFactory(week, params)
         mockft = D3RParameters()
         mockft.connect = Mock()
         mockft.disconnect = Mock()
         mockft.get_remote_submission_dir = Mock(return_value='/remote')
         mockft.list_dirs = Mock(return_value=['yo'])
         mockft.list_files = Mock(return_value=['hi',
                                                'celpp_week13_2015' + dr +
                                                'dname.tar.gz',
                                                'celpp_week13_2016' + dr +
                                                'yuck.tar.gz'])
         fac.set_file_transfer(mockft)
         tlist = fac.get_external_data_submissions()
         self.assertEqual(len(tlist), 0)
         mockft.list_dirs.assert_called_with('/remote')
         mockft.list_files.assert_called_with('/remote/yo')
     finally:
         shutil.rmtree(temp_dir)
Ejemplo n.º 3
0
 def test_get_submission_dirs_list_is_none(self):
     params = D3RParameters()
     mockft = D3RParameters()
     mockft.list_dirs = Mock(return_value=None)
     fac = ExternalDataSubmissionFactory('/foo', params)
     fac.set_file_transfer(mockft)
     self.assertEqual(len(fac._get_submission_dirs('ha')), 0)
     mockft.list_dirs.assert_called_with('ha')
Ejemplo n.º 4
0
 def test_get_external_data_submissions_no_dirs(self):
     params = D3RParameters()
     fac = ExternalDataSubmissionFactory('/foo', params)
     mockft = D3RParameters()
     mockft.list_dirs = Mock(return_value=[])
     fac.set_file_transfer(mockft)
     tlist = fac.get_external_data_submissions()
     self.assertEqual(len(tlist), 0)
Ejemplo n.º 5
0
 def test_get_challenge_data_package_file_no_files(self):
     params = D3RParameters()
     mockft = D3RParameters()
     mockft.list_files = Mock(return_value=[])
     fac = ExternalDataSubmissionFactory('/foo', params)
     fac.set_file_transfer(mockft)
     dlist = fac._get_challenge_data_package_file('/remote', 'dname')
     self.assertEqual(dlist, None)
     mockft.list_files.assert_called_with('/remote/dname')
Ejemplo n.º 6
0
 def test_get_submission_dirs_one_dir(self):
     params = D3RParameters()
     mockft = D3RParameters()
     mockft.list_dirs = Mock(return_value=['somedir'])
     fac = ExternalDataSubmissionFactory('/foo', params)
     fac.set_file_transfer(mockft)
     dlist = fac._get_submission_dirs('ha')
     self.assertEqual(dlist[0], 'somedir')
     mockft.list_dirs.assert_called_with('ha')
Ejemplo n.º 7
0
    def test_externaldatasubmissionfactory_getter_setter(self):
        params = D3RParameters()
        params.ha = 'hi'
        fac = ExternalDataSubmissionFactory('/foo', params)
        self.assertEqual(fac.get_file_transfer(), None)
        self.assertEqual(fac.get_path(), '/foo')
        self.assertEqual(fac.get_args().ha, 'hi')

        fac.set_file_transfer('yo')
        self.assertEqual(fac.get_file_transfer(), 'yo')
Ejemplo n.º 8
0
 def test_get_challenge_data_package_file_no_match(self):
     temp_dir = tempfile.mkdtemp()
     try:
         dr = ExternalDataSubmissionFactory.DOCKEDRESULTS
         year = os.path.join(temp_dir, '2016')
         week = os.path.join(year, 'dataset.week.13')
         os.makedirs(week)
         params = D3RParameters()
         mockft = D3RParameters()
         mockft.list_files = Mock(return_value=['hi', 'celpp_week13_2015_' +
                                                dr + '_dname.tar.gz',
                                                'celpp_week13_2016' + dr +
                                                'yuck.tar.gz'])
         fac = ExternalDataSubmissionFactory(week, params)
         fac.set_file_transfer(mockft)
         dlist = fac._get_challenge_data_package_file('/remote', 'dname')
         self.assertEqual(dlist, None)
         mockft.list_files.assert_called_with('/remote/dname')
     finally:
         shutil.rmtree(temp_dir)