Implement FilePointer
This commit is contained in:
+11
-3
@@ -1,4 +1,6 @@
|
||||
import tempfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from pprint import pprint as print
|
||||
from time import sleep
|
||||
|
||||
@@ -13,9 +15,10 @@ from grung.exceptions import PointerReferenceError, UniqueConstraintError
|
||||
|
||||
@pytest.fixture
|
||||
def db():
|
||||
_db = GrungDB.with_schema(examples, storage=MemoryStorage)
|
||||
yield _db
|
||||
print(_db)
|
||||
with tempfile.TemporaryDirectory() as path:
|
||||
_db = GrungDB.with_schema(examples, path=Path(path), storage=MemoryStorage)
|
||||
yield _db
|
||||
print(_db)
|
||||
|
||||
|
||||
def test_crud(db):
|
||||
@@ -153,10 +156,12 @@ def test_mapping(db):
|
||||
name="The Impossible Kid",
|
||||
credits={"Produced By": "Aesop Rock", "Lyrics By": "Aesop Rock", "Puke in the MeowMix By": "Kirby"},
|
||||
tracks=["Mystery Fish", "Rings", "Lotta Years", "Dorks"],
|
||||
cover=b"some jpg data",
|
||||
)
|
||||
)
|
||||
assert album.credits["Produced By"] == "Aesop Rock"
|
||||
assert album.tracks[0] == "Mystery Fish"
|
||||
assert album.cover == b"some jpg data"
|
||||
|
||||
aes = db.save(
|
||||
examples.Artist(
|
||||
@@ -170,3 +175,6 @@ def test_mapping(db):
|
||||
assert album.name in aes.albums
|
||||
assert aes.albums[album.name].uid == album.uid
|
||||
assert "Kirby" in aes.albums[album.name].credits.values()
|
||||
|
||||
location_on_disk = db.path / album._metadata.fields["cover"].relpath(album)
|
||||
assert location_on_disk.read_bytes() == album.cover
|
||||
|
||||
Reference in New Issue
Block a user