diff --git a/test/test_parsing.py b/test/test_parsing.py index e51c002..c1738db 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -1,69 +1,40 @@ from socials_util import * +import pytest -def test_parsing(): - assert determine_social_from_url('http://www.twitter.com/dril').social_id == 'dril' - assert determine_social_from_url('http://worstdril.tumblr.com/') - assert ( - determine_social_from_url('https://deep-dark-fears.tumblr.com').social_id - == 'deep-dark-fears' - ) - assert ( - determine_social_from_url('https://www.etsy.com/shop/aleksiremesart').social_id - == 'aleksiremesart' - ) - assert ( - determine_social_from_url('https://ko-fi.com/A627LI1/shop').social_id - == 'A627LI1' - ) - assert ( - determine_social_from_url('https://ko-fi.com/A627LI1/').social_id == 'A627LI1' - ) - assert ( - determine_social_from_url( - 'https://www.facebook.com/fredagscafeen.dk/' - ).social_id - == 'fredagscafeen.dk' - ) - assert ( - determine_social_from_url( - 'https://www.tiktok.com/@depthsofwikipedia?lang=en' - ).social_id - == 'depthsofwikipedia' - ) - assert ( - determine_social_from_url('https://www.pixiv.net/users/14866303').social_id - == '14866303' - ) - assert ( - determine_social_from_url( - 'https://www.pixiv.net/member.php?id=109710' - ).social_id - == '109710' - ) - assert ( - determine_social_from_url('https://www.deviantart.com/solquiet').social_site_id - == SocialSiteId.DEVIANT_ART_ACCOUNT - ) - assert ( - determine_social_from_url('https://solquiet.deviantart.com/').social_site_id - == SocialSiteId.DEVIANT_ART_ACCOUNT - ) - assert ( - determine_social_from_url('https://cohost.org/example').social_site_id - == SocialSiteId.COHOST_PROFILE - ) +PARSABLE_SOCIAL_IDS = [ + ('http://www.twitter.com/dril', 'dril'), + ('http://worstdril.tumblr.com/', 'worstdril'), + ('https://deep-dark-fears.tumblr.com', 'deep-dark-fears'), + ('https://www.etsy.com/shop/aleksiremesart', 'aleksiremesart'), + ('https://ko-fi.com/A627LI1/shop', 'A627LI1'), + ('https://ko-fi.com/A627LI1/', 'A627LI1'), + ('https://www.facebook.com/fredagscafeen.dk/', 'fredagscafeen.dk'), + ('https://www.tiktok.com/@depthsofwikipedia?lang=en', 'depthsofwikipedia'), + ('https://www.pixiv.net/users/14866303', '14866303'), + ('https://www.pixiv.net/member.php?id=109710', '109710'), +] - INSTAGRAMS = [ - 'https://instagram.com/_richardparry_', - 'https://instagram.com/j_kmor/', - 'https://instagram.com/cullensartbox/', - 'https://www.instagram.com/timkongart/', - 'https://www.instagram.com/kcn.wu/', - 'https://www.instagram.com/itsbettyjiang', - ] +PARSABLE_SOCIAL_SITE_IDS = [ + ('https://www.deviantart.com/solquiet', SocialSiteId.DEVIANT_ART_ACCOUNT), + ('https://solquiet.deviantart.com/', SocialSiteId.DEVIANT_ART_ACCOUNT), + ('https://cohost.org/example', SocialSiteId.COHOST_PROFILE), + ('https://instagram.com/_richardparry_', SocialSiteId.INSTAGRAM_PAGE), + ('https://instagram.com/j_kmor/', SocialSiteId.INSTAGRAM_PAGE), + ('https://instagram.com/cullensartbox/', SocialSiteId.INSTAGRAM_PAGE), + ('https://www.instagram.com/timkongart/', SocialSiteId.INSTAGRAM_PAGE), + ('https://www.instagram.com/kcn.wu/', SocialSiteId.INSTAGRAM_PAGE), + ('https://www.instagram.com/itsbettyjiang', SocialSiteId.INSTAGRAM_PAGE), +] - for ig in INSTAGRAMS: - assert ( - determine_social_from_url(ig).social_site_id == SocialSiteId.INSTAGRAM_PAGE - ) + +@pytest.mark.parametrize('url,expected_social_id', PARSABLE_SOCIAL_IDS) +def test_parse_social_ids(url, expected_social_id): + social_link = determine_social_from_url(url) + assert social_link.social_id == expected_social_id + assert social_link.social_site_id is not None + + +@pytest.mark.parametrize('url,expected_social_site_id', PARSABLE_SOCIAL_SITE_IDS) +def test_parse_social_site_ids(url, expected_social_site_id): + assert determine_social_from_url(url).social_site_id == expected_social_site_id