1
0
socials-util/test/test_parsing.py
Jon Michael Aanes f4a71899e0
Some checks failed
Python Package / Python-Test (push) Successful in 20s
Python Package / Python-Package (push) Failing after 22s
Additional tests
2024-05-26 10:35:30 +02:00

89 lines
3.3 KiB
Python

import pytest
from socials_util import *
PARSABLE_SOCIAL_IDS_COMBINED = [
# Tumblr formats
('https://triviallytrue.tumblr.com/', SocialSiteId.TUMBLR, 'triviallytrue'),
('https://tumblr.com/triviallytrue', SocialSiteId.TUMBLR, 'triviallytrue'),
('https://tumblr.com/blog/triviallytrue', SocialSiteId.TUMBLR, 'triviallytrue'),
(
'https://tumblr.com/blog/view/triviallytrue',
SocialSiteId.TUMBLR,
'triviallytrue',
),
('https://www.tumblr.com/triviallytrue', SocialSiteId.TUMBLR, 'triviallytrue'),
('https://www.tumblr.com/blog/triviallytrue', SocialSiteId.TUMBLR, 'triviallytrue'),
(
'https://www.tumblr.com/blog/view/triviallytrue',
SocialSiteId.TUMBLR,
'triviallytrue',
),
# Cohost formats
(
'https://cohost.org/andrewelmore?page=0',
SocialSiteId.COHOST_PROFILE,
'andrewelmore',
),
(
'https://cohost.org/andrewelmore',
SocialSiteId.COHOST_PROFILE,
'andrewelmore',
),
# Reddit formats
('https://old.reddit.com/user/Harpsibored/submitted/',
SocialSiteId.REDDIT_USER ,
'Harpsibored',
),
('https://old.reddit.com/user/Harpsibored/submitted',
SocialSiteId.REDDIT_USER ,
'Harpsibored',
),
('https://old.reddit.com/user/Harpsibored/',
SocialSiteId.REDDIT_USER ,
'Harpsibored',
),
('https://old.reddit.com/user/Harpsibored',
SocialSiteId.REDDIT_USER ,
'Harpsibored',
),
]
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'),
] + [(a, c) for (a, b, c) in PARSABLE_SOCIAL_IDS_COMBINED]
PARSABLE_SOCIAL_SITE_IDS = [
('https://www.deviantart.com/solquiet', SocialSiteId.DEVIANT_ART_ACCOUNT),
('https://solquiet.deviantart.com/', SocialSiteId.DEVIANT_ART_ACCOUNT),
('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),
] + [(a, b) for (a, b, c) in PARSABLE_SOCIAL_IDS_COMBINED]
@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, url
assert social_link.social_site_id is not None, url
@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, url