Exemplo n.º 1
0
 def test_find_file_in_subdir(self, testfs_fat_stable1):
     """ Test if finding file in a multiple nested direcotry works """
     for img_path in testfs_fat_stable1:
         with open(img_path, 'rb') as img_stream:
             # create FAT object
             fatfs = create_fat(img_stream)
             result = fatfs.find_file(
                 "onedirectory/nested_directory/royce.txt")
Exemplo n.º 2
0
 def test_find_non_existing(self, testfs_fat_stable1):
     # Test finding a non existing file
     for img_path in testfs_fat_stable1:
         with open(img_path, 'rb') as img_stream:
             # create FAT object
             fatfs = create_fat(img_stream)
             with pytest.raises(Exception):
                 fatfs.find_file("i-dont-exist")
Exemplo n.º 3
0
 def test_write_last_allocated(self, testfs_fat_stable1):
     """
     test if writing last_allocated_cluster into FAT32 FS INFO sector works
     correctly
     """
     img_path = testfs_fat_stable1[2]
     with open(img_path, 'rb+') as img_stream:
         # create FAT32 object
         fatfs = create_fat(img_stream)
         orig_alloc_cluster = fatfs.pre.last_allocated_data_cluster
         # write new last_allocated_cluster
         new_value = 1337
         fatfs.write_last_allocated(new_value)
         # test if new last_allocated_cluster value was wriiten to disk
         img_stream.seek(0)
         fatfs2 = create_fat(img_stream)
         assert fatfs2.pre.last_allocated_data_cluster == new_value
         # test if new last_allocated_cluster value was correctly reread
         assert fatfs.pre.last_allocated_data_cluster == new_value
         # restore old last_allocated_cluster count
         fatfs.write_last_allocated(orig_alloc_cluster)
Exemplo n.º 4
0
 def test_write_free_cluster(self, testfs_fat_stable1):
     """
     test if writing free cluster count into FAT32 FS INFO sector works
     correctly
     """
     img_path = testfs_fat_stable1[2]
     with open(img_path, 'rb+') as img_stream:
         # create FAT32 object
         fatfs = create_fat(img_stream)
         orig_free_clusters = fatfs.pre.free_data_cluster_count
         # write new free cluster count
         new_value = 1337
         fatfs.write_free_clusters(new_value)
         # test if new free cluster count was wriiten to disk
         img_stream.seek(0)
         fatfs2 = create_fat(img_stream)
         assert fatfs2.pre.free_data_cluster_count == new_value
         # test if new free cluster count was correctly reread
         assert fatfs.pre.free_data_cluster_count == new_value
         # restore old free cluster count
         fatfs.write_free_clusters(orig_free_clusters)
Exemplo n.º 5
0
 def test_find_file(self, testfs_fat_stable1):
     for img_path in testfs_fat_stable1:
         with open(img_path, 'rb') as img_stream:
             # create FAT object
             fatfs = create_fat(img_stream)
             result = fatfs.find_file("long_file.txt")
             # check for file attibutes
             assert result.parsed.name == b'LONG_F~1'
             assert result.parsed.extension == b'TXT'
             assert not result.parsed.attributes.unused
             assert not result.parsed.attributes.device
             assert result.parsed.attributes.archive
             assert not result.parsed.attributes.subDirectory
             assert not result.parsed.attributes.volumeLabel
             assert not result.parsed.attributes.system
             assert not result.parsed.attributes.hidden
             assert not result.parsed.attributes.readonly
             assert result.parsed.fileSize == 8001