Пример #1
0
 def test_nested_directories_skip_parents(self):
     local_file1 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/joe.txt', need_to_send=True)
     local_file2 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/data.txt', need_to_send=False)
     local_file3 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/results.txt', need_to_send=True)
     grandchild_folder = MagicMock(kind=KindType.folder_str,
                                   path="/data/2017/08/flyresults",
                                   children=[local_file1, local_file2, local_file3],
                                   remote_id=None)
     child_folder = MagicMock(kind=KindType.folder_str,
                              path="/data/2017/08",
                              children=[grandchild_folder],
                              remote_id='355')
     parent_folder = MagicMock(kind=KindType.folder_str,
                               path="/data/2017",
                               children=[child_folder],
                               remote_id='123')
     local_project = MagicMock(kind=KindType.project_str, children=[parent_folder])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     expected_results = [
         '/data/2017/08/flyresults',
         '/data/2017/08/flyresults/joe.txt',
         '/data/2017/08/flyresults/results.txt',
     ]
     self.assertEqual(expected_results, upload_dry_run.upload_items)
Пример #2
0
 def test_nested_directories_skip_parents(self):
     local_file1 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/joe.txt', need_to_send=True)
     local_file2 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/data.txt', need_to_send=False)
     local_file3 = MagicMock(kind=KindType.file_str, path='/data/2017/08/flyresults/results.txt', need_to_send=True)
     grandchild_folder = MagicMock(kind=KindType.folder_str,
                                   path="/data/2017/08/flyresults",
                                   children=[local_file1, local_file2, local_file3],
                                   remote_id=None)
     child_folder = MagicMock(kind=KindType.folder_str,
                              path="/data/2017/08",
                              children=[grandchild_folder],
                              remote_id='355')
     parent_folder = MagicMock(kind=KindType.folder_str,
                               path="/data/2017",
                               children=[child_folder],
                               remote_id='123')
     local_project = MagicMock(kind=KindType.project_str, children=[parent_folder])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     expected_results = [
         '/data/2017/08/flyresults',
         '/data/2017/08/flyresults/joe.txt',
         '/data/2017/08/flyresults/results.txt',
     ]
     self.assertEqual(expected_results, upload_dry_run.upload_items)
Пример #3
0
 def test_some_files(self):
     local_file1 = MagicMock(kind=KindType.file_str, path='joe.txt', need_to_send=True)
     local_file2 = MagicMock(kind=KindType.file_str, path='data.txt', need_to_send=False)
     local_file3 = MagicMock(kind=KindType.file_str, path='results.txt', need_to_send=True)
     local_project = MagicMock(kind=KindType.project_str, children=[local_file1, local_file2, local_file3])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     self.assertEqual(['joe.txt', 'results.txt'], upload_dry_run.upload_items)
Пример #4
0
 def test_some_files(self):
     local_file1 = MagicMock(kind=KindType.file_str, path='joe.txt', need_to_send=True)
     local_file2 = MagicMock(kind=KindType.file_str, path='data.txt', need_to_send=False)
     local_file3 = MagicMock(kind=KindType.file_str, path='results.txt', need_to_send=True)
     local_project = MagicMock(kind=KindType.project_str, children=[local_file1, local_file2, local_file3])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     self.assertEqual(['joe.txt', 'results.txt'], upload_dry_run.upload_items)
Пример #5
0
 def dry_run_report(self):
     """
     Returns text displaying the items that need to be uploaded or a message saying there are no files/folders
     to upload.
     :return: str: report text
     """
     project_uploader = ProjectUploadDryRun()
     project_uploader.run(self.local_project)
     items = project_uploader.upload_items
     if not items:
         return "\n\nNo changes found. Nothing needs to be uploaded.\n\n"
     else:
         result = "\n\nFiles/Folders that need to be uploaded:\n"
         for item in items:
             result += "{}\n".format(item)
         result += "\n"
         return result
Пример #6
0
 def test_single_empty_existing_directory(self):
     local_file = MagicMock(kind=KindType.folder_str, children=[], path='joe', remote_id='abc')
     local_project = MagicMock(kind=KindType.project_str, children=[local_file])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     self.assertEqual([], upload_dry_run.upload_items)
Пример #7
0
 def test_single_empty_existing_directory(self):
     local_file = MagicMock(kind=KindType.folder_str, children=[], path='joe', remote_id='abc')
     local_project = MagicMock(kind=KindType.project_str, children=[local_file])
     upload_dry_run = ProjectUploadDryRun()
     upload_dry_run.run(local_project)
     self.assertEqual([], upload_dry_run.upload_items)