Пример #1
0
def test_scan_tar_files():
    """Unit test for method scan, compressed tar file case."""
    file_io = FileIO()

    for ffile in os.listdir(TEST_TAR_LOCATION):
        for dfile in file_io.scan(os.path.join(TEST_TAR_LOCATION, ffile)):
            assert os.path.exists(dfile)
Пример #2
0
def test_scan_scan_xz():
    """ Unit test for scan method, lzma case. """
    file_io = FileIO()

    for method_row, util_row in zip(file_io.scan(TEST_CSV_XZ),
                                    util_test_csv(TEST_CSV)):
        assert method_row == util_row
Пример #3
0
def test_scan_scan_bzip2():
    """ Unit test for scan method, gzip case. """
    file_io = FileIO()

    for method_row, util_row in zip(file_io.scan(TEST_CSV_BZ2),
                                    util_test_csv(TEST_CSV)):
        assert method_row == util_row
Пример #4
0
    def test_scan_unknown_file(self):
        """
        Unit test for scan method, unknown file case
        """
        file_io = FileIO()

        with self.assertRaises(FileTypeNotSupportedYet):
            next(file_io.scan(TEST_UNKNOWN))
Пример #5
0
def test_scan_csv():
    """ Unit test for scan method, txt or csv case. """

    file_io = FileIO()

    for method_row, util_row in zip(file_io.scan(TEST_CSV),
                                    util_test_csv(TEST_CSV)):
        assert method_row == util_row
Пример #6
0
def test_scan_directory():
    """
    Unit test for scan method, directory case
    """
    file_io = FileIO()

    test_against_tree = [
        abspath(f'{TEST_SCAN_DIR}{ffile}')
        for ffile in [*walk(TEST_SCAN_DIR)][0][-1]
    ]

    test_current_tree = [*file_io.scan(abspath(TEST_SCAN_DIR))]

    assert test_current_tree == test_against_tree
Пример #7
0
    def test_scan_file(self):
        """ Unit test for scan method, file case."""
        file_io = FileIO()

        with self.assertRaises(FileScanNotPossible):
            assert next(file_io.scan(TEST_LOCAL)) == TEST_LOCAL