コード例 #1
0
def test_scan_compressed_tar_file_http():
    """Unit test for method scan_compressed_tar_file, http case."""
    test_uri = 'http://localhost:8888/images.tar.xz'
    test_file_reader = 'r|xz'

    file_io = FileIO()

    for ffile in file_io.scan_compressed_tar_file(test_uri, test_file_reader):
        assert os.path.exists(ffile)
コード例 #2
0
def test_scan_compressed_tar_file_local():
    """Unit test for method scan_compressed_tar_file, local case."""
    test_tar_compressed_file_readers = {
        'TZ2': 'r:bz2',
        'TGZ': 'r:gz',
        'TXZ': 'r:xz'
    }

    file_io = FileIO()

    for ffile in os.listdir(TEST_TAR_LOCATION):
        test_file_type = mimetypes.guess_type(
            os.path.join(TEST_TAR_LOCATION, ffile))[1]

        for dfile in file_io.scan_compressed_tar_file(
                os.path.join(TEST_TAR_LOCATION, ffile),
                test_tar_compressed_file_readers[TarCompressedTypes.name(
                    test_file_type)]):
            assert os.path.exists(dfile)