Skip to content

Commit

Permalink
Added test for validating feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Nov 19, 2024
1 parent 4f3d591 commit f87f300
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
25 changes: 23 additions & 2 deletions sausage_bot/test/feeds_core_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pytest
import pytest_asyncio
from sausage_bot.util import file_io
from sausage_bot.util import file_io, feeds_core


def test_check_similarity_return_number_or_none():
Expand All @@ -13,3 +12,25 @@ def test_check_similarity_return_number_or_none():
link3 = False
assert file_io.check_similarity(link1, link2) is link2
assert file_io.check_similarity(link1, link3) is None


async def test_check_feed_validity_url():
good_url1 = 'https://open.spotify.com/show/7CJKujLFxINFP3G4zns6nw?'\
'si=QM4HOzU5RlGuDOEOVLOtCQ'
good_url2 = 'https://www.metalsucks.net/category/'\
'shit-that-comes-out-today/feed/'
good_url3 = 'https://rss.kode24.no/'
bad_url1 = 'https://www.youtube.com'
bad_url2 = ''

out_good1 = await feeds_core.check_feed_validity(good_url1)
out_good2 = await feeds_core.check_feed_validity(good_url2)
out_good3 = await feeds_core.check_feed_validity(good_url3)
out_bad1 = await feeds_core.check_feed_validity(bad_url1)
out_bad2 = await feeds_core.check_feed_validity(bad_url2)

assert out_good1 is True
assert out_good2 is True
assert out_good3 is True
assert out_bad1 is False
assert out_bad2 is None
14 changes: 14 additions & 0 deletions sausage_bot/test/net_io_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
from sausage_bot.util import net_io


async def test_check_spotify_podcast_url():
good_url1 = 'https://open.spotify.com/show/7CJKujLFxINFP3G4zns6nw?si=QM4HOzU5RlGuDOEOVLOtCQ'
good_url2 = 'https://open.spotify.com/show/47qpUkCsSOLCkda3oE710f?si=5fb79d4d90ea43bd'
# This lacks the `?si=...` in the end, but is still accepted
good_url3 = 'https://open.spotify.com/show/47qpUkCsSOLCkda3oE710f'
# Obviously not a spotify link
bad_url1 = 'https://www.youtube.com'

assert type(await net_io.check_spotify_podcast(good_url1)) is int
assert type(await net_io.check_spotify_podcast(good_url2)) is int
assert type(await net_io.check_spotify_podcast(good_url3)) is int
assert await net_io.check_spotify_podcast(bad_url1) is False


async def test_make_event_start_stop():
date_yes, time_yes = ('17.05.2022', '21:00')
date_yes, time_no = ('17.05.2022', '671:00')
Expand Down

0 comments on commit f87f300

Please sign in to comment.