feat: monitoring data model (WatchedArtist, MonitoredRelease, Request link)

This commit is contained in:
Jonathan
2026-07-11 12:07:09 +02:00
parent 915bd96cd3
commit ec85016d88
4 changed files with 169 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
from tests.conftest import insert_monitored_release, insert_watched_artist
def test_watched_artist_and_release_round_trip(conn):
artist_id = insert_watched_artist(conn, mbid="mbid-1", name="John Mayer", auto_monitor_future=True)
rel_id = insert_monitored_release(
conn, watched_artist_id=artist_id, artist_mbid="mbid-1", artist_name="John Mayer",
rg_mbid="rg-1", album="Continuum", primary_type="Album",
secondary_types=["Live"], first_release_date="2006-09-12", monitored=True,
)
with conn.cursor() as cur:
cur.execute(
'SELECT "watchedArtistId", album, "primaryType", "secondaryTypes", '
'monitored, state FROM "MonitoredRelease" WHERE id = %s',
(rel_id,),
)
row = cur.fetchone()
assert row == (artist_id, "Continuum", "Album", ["Live"], True, "wanted")
def test_request_has_nullable_monitored_release_link(conn):
rel_id = insert_monitored_release(
conn, watched_artist_id=None, artist_mbid="mbid-2", artist_name="X",
rg_mbid="rg-2", album="Y", monitored=True,
)
with conn.cursor() as cur:
cur.execute(
'INSERT INTO "Request" (id, artist, album, status, "monitoredReleaseId", "createdAt") '
"VALUES (gen_random_uuid()::text, 'X', 'Y', 'pending', %s, now()) RETURNING id",
(rel_id,),
)
req_id = cur.fetchone()[0]
conn.commit()
with conn.cursor() as cur:
cur.execute('SELECT "monitoredReleaseId" FROM "Request" WHERE id = %s', (req_id,))
assert cur.fetchone()[0] == rel_id