"""Tests for exception handler.""" from podcast.constants import stores def test_get_stores_handler(fixture_client): """Test get stores handler.""" result = fixture_client.get('/stores') assert result.json['items'] == [ {'id': 1, 'name': stores.APPLE_PODCAST}, {'id': 2, 'name': stores.SPOTIFY}, {'id': 3, 'name': stores.STITCHER}, {'id': 4, 'name': stores.CASTBOX}, {'id': 5, 'name': stores.POCKET_CASTS}, {'id': 6, 'name': stores.RADIO_PUBLIC}, {'id': 7, 'name': stores.PODCAST_ADDICT}, {'id': 8, 'name': stores.PLAYER_FM}, {'id': 9, 'name': stores.GOOGLE_PODCAST}, {'id': 10, 'name': stores.DEEZER}, {'id': 11, 'name': stores.IHEART}, {'id': 12, 'name': stores.WEBSITE_EMBED_CODE}, {'id': 13, 'name': stores.PANDORA} ] def test_get_podcast_links_handler(fixture_client): """Test get podcast links handler.""" result = fixture_client.get('/podcast-links/podcast/1') assert result.json['items'] == [ {'id': 1, 'store_id': 1, 'podcast_id': 1, 'link': 'https://www.link.com'}, {'id': 2, 'store_id': 2, 'podcast_id': 1, 'link': 'https://www.spotify.com/abc'} ] def test_create_podcast_links_handler(fixture_client): """Test create podcast links handler saves and overwrites.""" data = { 'podcast_id': 1, 'links': [{ 'store_id': 1, 'link': 'link' }] } result = fixture_client.post('/podcast-links', json=data) assert result.json['items'] == [ {'id': 4, 'link': 'link', 'podcast_id': 1, 'store_id': 1} ] data = { 'podcast_id': 1, 'links': [{ 'store_id': 2, 'link': 'link2' }] } result = fixture_client.post('/podcast-links', json=data) assert result.json['items'] == [ {'id': 4, 'link': 'link2', 'podcast_id': 1, 'store_id': 2} ]