Пример #1
0
    def test_should_print_wrapper_only_given_no_folders(self):
        walker = TreeWalker(self.config, self.storage)

        walker.walk()

        self.mock_print.assert_not_called()
        self.mock_logger.info.assert_called_once_with(
            "0 directories, 0 files read in 0.0 sec")
Пример #2
0
    def test_should_not_print_root_files_given_root_files_disabled(self):
        self.config.root_files = False
        walker = TreeWalker(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_called_once_with("0 directories, 0 files read in 0.0 sec")
Пример #3
0
    def test_should_print_wrapper_only_given_empty_folders(self):
        walker = TreeWalker(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_called_once_with("0 directories, 0 files (excluding 1 empty directories) read in 0.0 sec")
Пример #4
0
    def test_should_print_checksum_given_file_has_checksum(self):
        walker = TreeWalker(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([
            call(u"└─── A Folder".encode('utf-8')),
            call(u"    └─── C File [abc123]".encode('utf-8')),
            call("1 directories, 1 files read in 0.0 sec")
        ])
Пример #5
0
    def test_should_print_root_files_given_root_files_enabled(self):
        self.config.root_files = True
        walker = TreeWalker(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(u"├─── A File".encode('utf-8')),
            call(u"└─── B File".encode('utf-8')),
            call("0 directories, 2 files read in 0.0 sec")
        ])
Пример #6
0
    def test_should_print_folder_files(self):
        walker = TreeWalker(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([
            call(u"└─── A Folder".encode('utf-8')),
            call(u"    ├─── A File".encode('utf-8')),
            call(u"    └─── B File".encode('utf-8')),
            call("1 directories, 2 files read in 0.0 sec")
        ])
Пример #7
0
    def test_should_not_print_connector_when_printing_root_files_given_folders_are_hidden(self):
        self.config.root_files = True
        walker = TreeWalker(self.config, self.storage)
        helpers.setup_storage(self.storage, [
            { 'folder': self.root_folder, 'files': [self.file_one, self.file_two] },
            { 'folder': self.folder_one, 'files': [] }
        ])

        walker.walk()

        self.mock_print.assert_has_calls_exactly([
            call(u"├─── A File".encode('utf-8')),
            call(u"└─── B File".encode('utf-8')),
            call("0 directories, 2 files (excluding 1 empty directories) read in 0.0 sec")
        ])
Пример #8
0
    def test_should_print_only_folders_given_list_folders_enabled(self):
        self.config.list_folders = True
        walker = TreeWalker(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([
            call(u"├─── B Folder".encode('utf-8')),
            call(u"└─── A Folder".encode('utf-8')),
            call("2 directories read in 0.0 sec")
        ])
Пример #9
0
    def test_should_print_all_folders(self):
        walker = TreeWalker(self.config, self.storage)
        helpers.setup_storage(self.storage, [
            {'folder': self.folder_one, 'files': [self.file_one]},
            {'folder': self.folder_two, 'files': [self.file_two]}
        ])

        walker.walk()

        self.mock_print.assert_has_calls([
            call(u"├─── A Folder".encode('utf-8')),
            call(u"│   └─── A File".encode('utf-8')),
            call(u"│   ".encode('utf-8')),
            call(u"└─── B Folder".encode('utf-8')),
            call(u"    └─── B File".encode('utf-8'))
        ])
        self.mock_logger.info.assert_called_once_with(
            "2 directories, 2 files read in 0.0 sec")
Пример #10
0
    def test_should_print_root_files_given_root_files_enabled_and_folders_exist(self):
        self.config.root_files = True
        self.config.list_sort = False
        walker = TreeWalker(self.config, self.storage)
        helpers.setup_storage(self.storage, [
            { 'folder': self.root_folder, 'files': [self.file_three] },
            { 'folder': self.folder_one, 'files': [self.file_one] }
        ])

        walker.walk()

        self.mock_print.assert_has_calls([
            call(u"├─── C File [abc123]".encode('utf-8')),
            call(u"│   ".encode('utf-8')),
            call(u"└─── A Folder".encode('utf-8')),
            call(u"    └─── A File".encode('utf-8')),
            call("1 directories, 2 files read in 0.0 sec")
        ])
Пример #11
0
    def test_should_not_sort_folders_and_files_given_sort_disabled(self):
        self.config.list_sort = False
        walker = TreeWalker(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([
            call(u"├─── B Folder".encode('utf-8')),
            call(u"│   ├─── C File [abc123]".encode('utf-8')),
            call(u"│   └─── B File".encode('utf-8')),
            call(u"│   ".encode('utf-8')),
            call(u"└─── A Folder".encode('utf-8')),
            call(u"    └─── A File".encode('utf-8')),
            call("2 directories, 3 files read in 0.0 sec")
        ])