def test_stores_two_files(self, tmpdir): storage = LocalFileStorage(str(tmpdir)) storage.store("foo/first.txt", io.BytesIO(b"First Test File!")) storage.store("foo/second.txt", io.BytesIO(b"Second Test File!")) with open(os.path.join(str(tmpdir), "foo/first.txt"), "rb") as fp: assert fp.read() == b"First Test File!" with open(os.path.join(str(tmpdir), "foo/second.txt"), "rb") as fp: assert fp.read() == b"Second Test File!"
def test_stores_file(self, tmpdir): filename = str(tmpdir.join("testfile.txt")) with open(filename, "wb") as fp: fp.write(b"Test File!") storage_dir = str(tmpdir.join("storage")) storage = LocalFileStorage(storage_dir) storage.store("foo/bar.txt", filename) with open(os.path.join(storage_dir, "foo/bar.txt"), "rb") as fp: assert fp.read() == b"Test File!"
def test_stores_two_files(self, tmpdir): filename1 = str(tmpdir.join("testfile1.txt")) with open(filename1, "wb") as fp: fp.write(b"First Test File!") filename2 = str(tmpdir.join("testfile2.txt")) with open(filename2, "wb") as fp: fp.write(b"Second Test File!") storage_dir = str(tmpdir.join("storage")) storage = LocalFileStorage(storage_dir) storage.store("foo/first.txt", filename1) storage.store("foo/second.txt", filename2) with open(os.path.join(storage_dir, "foo/first.txt"), "rb") as fp: assert fp.read() == b"First Test File!" with open(os.path.join(storage_dir, "foo/second.txt"), "rb") as fp: assert fp.read() == b"Second Test File!"
def test_stores_file(self, tmpdir): storage = LocalFileStorage(str(tmpdir)) storage.store("foo/bar.txt", io.BytesIO(b"Test File!")) with open(os.path.join(str(tmpdir), "foo/bar.txt"), "rb") as fp: assert fp.read() == b"Test File!"