def test_should_print_header_only_given_no_folders(self):
        walker = CsvWalker(self.config, self.storage)

        walker.walk()

        self.mock_print.assert_has_calls_exactly(
            [call("Folder, Filename, Checksum"),
             call("\ndone in 0.0 sec")])
    def test_should_not_print_root_files_given_root_files_disabled(self):
        self.config.root_files = False
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage,
                              [{
                                  'folder': self.root_folder,
                                  'files': [self.file_one, self.file_two]
                              }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly(
            [call("Folder, Filename, Checksum"),
             call("\ndone in 0.0 sec")])
    def test_should_print_checksum_given_file_has_checksum(self):
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage, [{
            'folder': self.folder_one,
            'files': [self.file_three]
        }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly([
            call("Folder, Filename, Checksum"),
            call("A Folder, C File, abc123"),
            call("\ndone in 0.0 sec")
        ])
    def test_should_print_header_only_given_empty_folders(self):
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage, [{
            'folder': self.root_folder,
            'files': []
        }, {
            'folder': self.folder_one,
            'files': []
        }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly(
            [call("Folder, Filename, Checksum"),
             call("\ndone in 0.0 sec")])
    def test_should_print_folder_files(self):
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage,
                              [{
                                  'folder': self.folder_one,
                                  'files': [self.file_one, self.file_two]
                              }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly([
            call("Folder, Filename, Checksum"),
            call("A Folder, A File, None"),
            call("A Folder, B File, None"),
            call("\ndone in 0.0 sec")
        ])
示例#6
0
    def test_should_print_root_files_given_root_files_enabled(self):
        self.config.root_files = True
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage,
                              [{
                                  'folder': self.root_folder,
                                  'files': [self.file_one, self.file_two]
                              }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly([
            call("Folder, Filename, Checksum"),
            call(", A File, None"),
            call(", B File, None")
        ])
        self.mock_logger.info.assert_called_once_with("\ndone in 0.0 sec")
示例#7
0
    def test_should_print_only_folders_given_list_folders_enabled(self):
        self.config.list_folders = True
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage,
                              [{
                                  'folder': self.folder_two,
                                  'files': [self.file_three, self.file_two]
                              }, {
                                  'folder': self.folder_one,
                                  'files': [self.file_one]
                              }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly(
            [call("Folder"),
             call("B Folder"),
             call("A Folder")])
        self.mock_logger.info.assert_called_once_with("\ndone in 0.0 sec")
    def test_should_not_sort_folders_and_files_given_sort_disabled(self):
        self.config.list_sort = False
        walker = CsvWalker(self.config, self.storage)
        helpers.setup_storage(self.storage,
                              [{
                                  'folder': self.folder_two,
                                  'files': [self.file_three, self.file_two]
                              }, {
                                  'folder': self.folder_one,
                                  'files': [self.file_one]
                              }])

        walker.walk()

        self.mock_print.assert_has_calls_exactly([
            call("Folder, Filename, Checksum"),
            call("B Folder, C File, abc123"),
            call("B Folder, B File, None"),
            call("A Folder, A File, None"),
            call("\ndone in 0.0 sec")
        ])