split filepointer in to text and binary variants
This commit is contained in:
+26
-2
@@ -156,12 +156,10 @@ 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(
|
||||
@@ -176,5 +174,31 @@ def test_mapping(db):
|
||||
assert aes.albums[album.name].uid == album.uid
|
||||
assert "Kirby" in aes.albums[album.name].credits.values()
|
||||
|
||||
|
||||
def test_file_pointers(db):
|
||||
album = db.save(
|
||||
examples.Album(
|
||||
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",
|
||||
review="10/10 no notes",
|
||||
)
|
||||
)
|
||||
assert album.cover == b"some jpg data"
|
||||
assert album.review == "10/10 no notes"
|
||||
|
||||
db.save(
|
||||
examples.Artist(
|
||||
name="Aesop Rock",
|
||||
albums={"The Impossible Kid": album},
|
||||
)
|
||||
)
|
||||
|
||||
album = db.Album.get(doc_id=album.doc_id)
|
||||
|
||||
location_on_disk = db.path / album._metadata.fields["cover"].relpath(album)
|
||||
assert location_on_disk.read_bytes() == album.cover
|
||||
|
||||
location_on_disk = db.path / album._metadata.fields["review"].relpath(album)
|
||||
assert location_on_disk.read_text() == album.review
|
||||
|
||||
Reference in New Issue
Block a user