Ejemplo n.º 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 sec")
Ejemplo n.º 2
0
    def test_should_print_checksum_given_file_has_checksum(self):
        walker = TreeWalker(self.config, self.storage)
        tests.helpers.setup_storage(self.storage, [{
            'folder': self.folder_one,
            'files': [self.file_three]
        }])

        walker.walk()

        self.mock_print.assert_has_calls(
            [call("└─── A Folder"),
             call("    └─── C File [abc123]")])
        self.mock_logger.info.assert_called_once_with(
            "1 directories, 1 files read in 0 sec")
Ejemplo n.º 3
0
    def test_should_not_print_root_files_given_root_files_disabled(self):
        self.config.root_files = False
        walker = TreeWalker(self.config, self.storage)
        tests.helpers.setup_storage(
            self.storage, [{
                'folder': self.root_folder,
                'files': [self.file_one, self.file_two]
            }])

        walker.walk()

        self.mock_print.assert_not_called()
        self.mock_logger.info.assert_called_once_with(
            "0 directories, 0 files read in 0 sec")
Ejemplo n.º 4
0
    def test_should_print_root_files_given_root_files_enabled(self):
        self.config.root_files = True
        walker = TreeWalker(self.config, self.storage)
        tests.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("├─── A File"), call("└─── B File")])
        self.mock_logger.info.assert_called_once_with(
            "0 directories, 2 files read in 0 sec")
Ejemplo n.º 5
0
    def test_should_print_wrapper_only_given_empty_folders(self):
        walker = TreeWalker(self.config, self.storage)
        tests.helpers.setup_storage(self.storage, [{
            'folder': self.root_folder,
            'files': []
        }, {
            'folder': self.folder_one,
            'files': []
        }])

        walker.walk()

        self.mock_print.assert_not_called()
        self.mock_logger.info.assert_called_once_with(
            "0 directories, 0 files (excluding 1 empty directories) read in 0 sec"
        )
Ejemplo n.º 6
0
    def test_should_print_folder_files(self):
        walker = TreeWalker(self.config, self.storage)
        tests.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("└─── A Folder"),
            call("    ├─── A File"),
            call("    └─── B File")
        ])
        self.mock_logger.info.assert_called_once_with(
            "1 directories, 2 files read in 0 sec")
Ejemplo n.º 7
0
    def test_should_print_only_folders_given_list_folders_enabled(self):
        self.config.list_folders = True
        walker = TreeWalker(self.config, self.storage)
        tests.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("├─── B Folder"),
             call("└─── A Folder")])
        self.mock_logger.info.assert_called_once_with(
            "2 directories read in 0 sec")
Ejemplo n.º 8
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)
        tests.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("├─── A File"), call("└─── B File")])
        self.mock_logger.info.assert_called_once_with(
            "0 directories, 2 files (excluding 1 empty directories) read in 0 sec"
        )
Ejemplo n.º 9
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)
        tests.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("├─── C File [abc123]"),
            call("│   "),
            call("└─── A Folder"),
            call("    └─── A File")
        ])
        self.mock_logger.info.assert_called_once_with(
            "1 directories, 2 files read in 0 sec")