audio streaming app plyr.fm
38
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 2025.1210.061611 63 lines 1.9 kB view raw
1"""test database setup and basic operations.""" 2 3from sqlalchemy import select 4from sqlalchemy.ext.asyncio import AsyncSession 5 6from backend.models import Artist 7 8 9async def test_database_connection(db_session: AsyncSession): 10 """verify database connection works.""" 11 result = await db_session.execute(select(1)) 12 assert result.scalar() == 1 13 14 15async def test_create_artist(db_session: AsyncSession): 16 """verify we can create an artist record.""" 17 artist = Artist( 18 did="did:plc:test123", 19 handle="test.bsky.social", 20 display_name="test artist", 21 bio="test bio", 22 avatar_url="https://example.com/avatar.jpg", 23 ) 24 25 db_session.add(artist) 26 await db_session.commit() 27 await db_session.refresh(artist) 28 29 # verify the artist was created 30 assert artist.did == "did:plc:test123" 31 assert artist.handle == "test.bsky.social" 32 assert artist.display_name == "test artist" 33 34 35async def test_query_artist(db_session: AsyncSession): 36 """verify we can query artists.""" 37 # create an artist 38 artist = Artist( 39 did="did:plc:query123", 40 handle="query.bsky.social", 41 display_name="query test", 42 ) 43 db_session.add(artist) 44 await db_session.commit() 45 46 # query it back 47 result = await db_session.execute( 48 select(Artist).where(Artist.did == "did:plc:query123") 49 ) 50 queried_artist = result.scalar_one_or_none() 51 52 assert queried_artist is not None 53 assert queried_artist.handle == "query.bsky.social" 54 assert queried_artist.display_name == "query test" 55 56 57async def test_database_isolation(db_session: AsyncSession): 58 """verify tests are isolated - this should not see artists from other tests.""" 59 result = await db_session.execute(select(Artist)) 60 artists = result.scalars().all() 61 62 # if isolation works, we should have no artists from previous tests 63 assert len(artists) == 0