Skip to content

Commit

Permalink
snapshottest the new fns
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed May 6, 2024
1 parent cfe0dc5 commit 6582a3d
Show file tree
Hide file tree
Showing 3 changed files with 1,691 additions and 9 deletions.
24 changes: 15 additions & 9 deletions rose_cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ def dump_genre(c: Config, genre_name: str) -> str:

def dump_all_genres(c: Config) -> str:
out: list[dict[str, Any]] = []
for name in list_genres(c):
genre_releases = list_releases_delete_this(c, genre_filter=name.genre)
for e in list_genres(c):
genre_releases = list_releases_delete_this(c, genre_filter=e.genre)
releases = [release_to_json(r) for r in genre_releases]
out.append({"name": name, "releases": releases})
out.append(
{"name": e.genre, "only_new_releases": e.only_new_releases, "releases": releases}
)
return json.dumps(out)


Expand All @@ -205,10 +207,12 @@ def dump_label(c: Config, label_name: str) -> str:

def dump_all_labels(c: Config) -> str:
out: list[dict[str, Any]] = []
for name in list_labels(c):
label_releases = list_releases_delete_this(c, label_filter=name.label)
for e in list_labels(c):
label_releases = list_releases_delete_this(c, label_filter=e.label)
releases = [release_to_json(r) for r in label_releases]
out.append({"name": name, "releases": releases})
out.append(
{"name": e.label, "only_new_releases": e.only_new_releases, "releases": releases}
)
return json.dumps(out)


Expand All @@ -222,10 +226,12 @@ def dump_descriptor(c: Config, descriptor_name: str) -> str:

def dump_all_descriptors(c: Config) -> str:
out: list[dict[str, Any]] = []
for name in list_descriptors(c):
descriptor_releases = list_releases_delete_this(c, descriptor_filter=name.descriptor)
for e in list_descriptors(c):
descriptor_releases = list_releases_delete_this(c, descriptor_filter=e.descriptor)
releases = [release_to_json(r) for r in descriptor_releases]
out.append({"name": name, "releases": releases})
out.append(
{"name": e.descriptor, "only_new_releases": e.only_new_releases, "releases": releases}
)
return json.dumps(out)


Expand Down
48 changes: 48 additions & 0 deletions rose_cli/dump_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@

from rose import Config, MetadataMatcher
from rose_cli.dump import (
dump_all_artists,
dump_all_collages,
dump_all_descriptors,
dump_all_genres,
dump_all_labels,
dump_all_playlists,
dump_all_releases,
dump_all_tracks,
dump_artist,
dump_collage,
dump_descriptor,
dump_genre,
dump_label,
dump_playlist,
dump_release,
dump_track,
Expand Down Expand Up @@ -48,6 +56,46 @@ def test_dump_track(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_track(config, "t1")))


@pytest.mark.usefixtures("static_cache")
def test_dump_artist(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_artist(config, "Bass Man")))


@pytest.mark.usefixtures("static_cache")
def test_dump_artists(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_all_artists(config)))


@pytest.mark.usefixtures("static_cache")
def test_dump_genre(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_genre(config, "Deep House")))


@pytest.mark.usefixtures("static_cache")
def test_dump_genres(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_all_genres(config)))


@pytest.mark.usefixtures("static_cache")
def test_dump_label(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_label(config, "Silk Music")))


@pytest.mark.usefixtures("static_cache")
def test_dump_labels(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_all_labels(config)))


@pytest.mark.usefixtures("static_cache")
def test_dump_descriptor(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_descriptor(config, "Warm")))


@pytest.mark.usefixtures("static_cache")
def test_dump_descriptors(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_all_descriptors(config)))


@pytest.mark.usefixtures("static_cache")
def test_dump_collage(config: Config, snapshot: Any) -> None:
snapshot.assert_match(json.loads(dump_collage(config, "Rose Gold")))
Expand Down
Loading

0 comments on commit 6582a3d

Please sign in to comment.