Compare commits
No commits in common. "1cda90c0bcc36c3436befbf372aad8ccbfa64ab0" and "431962c02f2bdd718b767325277baa8c914f7124" have entirely different histories.
1cda90c0bc
...
431962c02f
|
@ -1,2 +1 @@
|
||||||
pytest
|
pytest
|
||||||
wikidata
|
|
||||||
|
|
|
@ -14,14 +14,7 @@ from enforce_typing import enforce_types
|
||||||
|
|
||||||
from socials_util._version import __version__
|
from socials_util._version import __version__
|
||||||
|
|
||||||
__all__ = [
|
__all__ = ['__version__', 'SocialSiteId', 'SocialLink', 'WikidataInfo', 'AGGERAGOR_SOCIALS', 'determine_social_from_url']
|
||||||
'__version__',
|
|
||||||
'SocialSiteId',
|
|
||||||
'SocialLink',
|
|
||||||
'WikidataInfo',
|
|
||||||
'AGGERAGOR_SOCIALS',
|
|
||||||
'determine_social_from_url',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class SocialSiteId(aenum.Enum):
|
class SocialSiteId(aenum.Enum):
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
import socials_util
|
|
||||||
|
|
||||||
|
|
||||||
def test_is_aggregator():
|
|
||||||
assert not socials_util.SocialSiteId.PAGE_WATCH.is_aggregator()
|
|
||||||
assert not socials_util.SocialSiteId.FALKON_PROFILE_BOOKMARKS.is_aggregator()
|
|
|
@ -1,14 +1,8 @@
|
||||||
import aenum
|
import aenum
|
||||||
import pytest
|
|
||||||
|
|
||||||
import socials_util
|
import socials_util
|
||||||
|
|
||||||
|
|
||||||
def test_re_social_path_validation():
|
|
||||||
with pytest.raises(ValueError, match='Redundant www: www.example.org'):
|
|
||||||
socials_util.re_social_path('www.example.org')
|
|
||||||
|
|
||||||
|
|
||||||
def test_extension():
|
def test_extension():
|
||||||
my_secret_site = aenum.extend_enum(socials_util.SocialSiteId, 'MY_SECRET_SITE', 666)
|
my_secret_site = aenum.extend_enum(socials_util.SocialSiteId, 'MY_SECRET_SITE', 666)
|
||||||
assert my_secret_site
|
assert my_secret_site
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import urllib.parse
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import socials_util
|
|
||||||
from socials_util import SocialLink, SocialSiteId, determine_social_from_url
|
from socials_util import SocialLink, SocialSiteId, determine_social_from_url
|
||||||
|
|
||||||
PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
|
PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str]] = [
|
||||||
# Tumblr formats
|
# Tumblr formats
|
||||||
('https://triviallytrue.tumblr.com/', SocialSiteId.TUMBLR, 'triviallytrue'),
|
('https://triviallytrue.tumblr.com/', SocialSiteId.TUMBLR, 'triviallytrue'),
|
||||||
('https://www.triviallytrue.tumblr.com/', SocialSiteId.TUMBLR, 'triviallytrue'),
|
('https://www.triviallytrue.tumblr.com/', SocialSiteId.TUMBLR, 'triviallytrue'),
|
||||||
|
@ -189,11 +186,6 @@ PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
|
||||||
# Cara
|
# Cara
|
||||||
('https://cara.app/simzart', SocialSiteId.CARA_PROFILE, 'simzart'),
|
('https://cara.app/simzart', SocialSiteId.CARA_PROFILE, 'simzart'),
|
||||||
('https://cara.app/simzart/all', SocialSiteId.CARA_PROFILE, 'simzart'),
|
('https://cara.app/simzart/all', SocialSiteId.CARA_PROFILE, 'simzart'),
|
||||||
# Mastodon
|
|
||||||
('https://idlethumbs.social/@testtest', SocialSiteId.MASTODON_PAGE, None),
|
|
||||||
('https://mastodon.example.org/testtest', SocialSiteId.MASTODON_PAGE, None),
|
|
||||||
# Feeds
|
|
||||||
('https://example.org/main.atom', SocialSiteId.RSS_FEED, None),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
NOT_PARSABLE = [
|
NOT_PARSABLE = [
|
||||||
|
@ -206,12 +198,10 @@ NOT_PARSABLE = [
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
('url', 'expected_social_site_id', 'expected_social_id'),
|
('url','expected_social_site_id','expected_social_id'),
|
||||||
PARSABLE_SOCIAL_IDS_COMBINED,
|
PARSABLE_SOCIAL_IDS_COMBINED,
|
||||||
)
|
)
|
||||||
def test_parse_social_ids(
|
def test_parse_social_ids(url: str, expected_social_site_id: SocialSiteId, expected_social_id: str) -> None:
|
||||||
url: str, expected_social_site_id: SocialSiteId, expected_social_id: str,
|
|
||||||
) -> None:
|
|
||||||
social_link: SocialLink | None = determine_social_from_url(url)
|
social_link: SocialLink | None = determine_social_from_url(url)
|
||||||
assert social_link is not None, url
|
assert social_link is not None, url
|
||||||
assert (social_link.social_id, social_link.social_site_id) == (
|
assert (social_link.social_id, social_link.social_site_id) == (
|
||||||
|
@ -223,20 +213,3 @@ def test_parse_social_ids(
|
||||||
@pytest.mark.parametrize('url', NOT_PARSABLE)
|
@pytest.mark.parametrize('url', NOT_PARSABLE)
|
||||||
def test_not_parsable(url: str) -> None:
|
def test_not_parsable(url: str) -> None:
|
||||||
assert determine_social_from_url(url) is None
|
assert determine_social_from_url(url) is None
|
||||||
|
|
||||||
|
|
||||||
def test_wrong_parse_type() -> None:
|
|
||||||
with pytest.raises(TypeError):
|
|
||||||
assert socials_util.to_parse_result(None)
|
|
||||||
|
|
||||||
|
|
||||||
def test_from_parse_result() -> None:
|
|
||||||
urlresult = urllib.parse.urlparse(
|
|
||||||
'https://old.reddit.com/user/Harpsibored/submitted/',
|
|
||||||
)
|
|
||||||
assert socials_util.to_parse_result(urlresult) is urlresult
|
|
||||||
|
|
||||||
|
|
||||||
def test_determine_social_from_url_internally() -> None:
|
|
||||||
with pytest.raises(TypeError):
|
|
||||||
assert socials_util.determine_social_from_url_internally(None)
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
import wikidata.client
|
|
||||||
|
|
||||||
import socials_util
|
|
||||||
|
|
||||||
|
|
||||||
def test_wikidata_properties():
|
|
||||||
wikidata_client = wikidata.client.Client()
|
|
||||||
wikidata_property = socials_util.SocialSiteId.RSS_FEED.wikidata_property(
|
|
||||||
wikidata_client,
|
|
||||||
)
|
|
||||||
assert wikidata_property is not None
|
|
Loading…
Reference in New Issue
Block a user