示例#1
0
    def setup_method(self):
        self.print_patch = patch('album_rsync.sync.print')
        self.mock_print = self.print_patch.start()
        self.logger_patch = patch('album_rsync.csv_walker.logger', create=True)
        self.logger_patch.start()
        self.choice_patch = patch('album_rsync.sync.choice')
        self.choice_patch.start().return_value = True

        self.config = MagicMock()
        self.config.dry_run = False
        self.src_storage = MagicMock()
        self.dest_storage = MagicMock()
        self.folder_one = Folder(id=1, name='A')
        self.folder_two = Folder(id=2, name='B')
        self.folder_three = Folder(id=3, name='C')
        self.folder_four = Folder(id=4, name='D')
        self.root_folder = RootFolder()
        self.file_one = File(id=1, name='A')
        self.file_two = File(id=1, name='B')

        self.sync = Sync(self.config, self.src_storage, self.dest_storage)
        self.mock = MagicMock()
        self.src_storage.copy_file = self.mock

        self.mock_delete_folder = MagicMock()
        self.mock_delete_folder.return_value = 1
        self.dest_storage.delete_folder = self.mock_delete_folder
示例#2
0
    def test_list_files_should_not_list_files_given_there_are_no_files(self):
        self.api.get_media_in_folder.return_value = []
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert not files
示例#3
0
    def test_list_files_should_return_files_given_there_are_files(
            self, files_fixture):
        self.api.get_media_in_folder.return_value = files_fixture
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert len(files) == 2
示例#4
0
    def test_list_files_should_not_list_file_given_its_excluded(
            self, files_fixture):
        self.config.exclude = 'image1'
        self.api.get_media_in_folder.return_value = files_fixture
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert len(files) == 1
        assert files[0].name == 'image2.jpg'
示例#5
0
    def setup_method(self):
        self.print_patch = patch('album_rsync.tree_walker.print', create=True)
        self.mock_print = self.print_patch.start()
        self.logger_patch = patch('album_rsync.tree_walker.logger',
                                  create=True)
        self.mock_logger = self.logger_patch.start()
        self.time_patch = patch('album_rsync.tree_walker.time.time',
                                create=True)
        self.time_patch.start().return_value = 0

        self.config = MagicMock()
        self.config.root_files = False
        self.config.list_folders = False
        self.config.list_sort = False
        self.storage = MagicMock()
        self.folder_one = Folder(id=1, name='A Folder')
        self.folder_two = Folder(id=2, name='B Folder')
        self.folder_three = Folder(id=3, name='C Folder')
        self.folder_four = Folder(id=4, name='D Folder')
        self.root_folder = RootFolder()
        self.file_one = File(id=1, name='A File')
        self.file_two = File(id=2, name='B File')
        self.file_three = File(id=3, name='C File', checksum='abc123')