Esempio n. 1
0
    def test_find(self):
        with FileSystem(":memory:", self.matryoshka) as fs:
            with File.create(fs, Path("folder1", "file"), self.example_file):
                pass
            with File.create(fs, Path("folder2", "file"), self.example_file):
                pass

            files = File.find(fs, Path("folder*", "file"))
            self.assertEqual(len(files), 2)
Esempio n. 2
0
    def test_load(self):
        output_file = Path(self.temp_directory.name, "loaded_example_file")
        example_path = Path("folder1", "file")

        with FileSystem(":memory:", self.matryoshka) as fs:
            with File.create(fs, example_path, self.example_file):
                pass
            with File(fs, example_path) as file:
                file.pull(output_file)

        with output_file.open("rb") as output:
            self.assertEqual(output.read(), b"1234")

        output_file.unlink()
Esempio n. 3
0
 def test_create(self):
     example_path = Path("folder1", "file")
     with FileSystem(":memory:", self.matryoshka) as fs:
         with File.create(fs, example_path, self.example_file) as file:
             self.assertEqual(file.size, 4)
             self.assertEqual(str(file), "/".join(example_path.parts))