Code quality
This commit is contained in:
parent
4ea9d71f53
commit
1396391fbb
|
@ -12,7 +12,9 @@ from dataclasses import dataclass
|
||||||
import aenum
|
import aenum
|
||||||
from enforce_typing import enforce_types
|
from enforce_typing import enforce_types
|
||||||
|
|
||||||
from socials_util._version import __version__ # noqa: F401
|
from socials_util._version import __version__
|
||||||
|
|
||||||
|
__all__ = ['__version__', 'SocialSiteId', 'SocialLink', 'WikidataInfo', 'AGGERAGOR_SOCIALS', 'determine_social_from_url']
|
||||||
|
|
||||||
|
|
||||||
class SocialSiteId(aenum.Enum):
|
class SocialSiteId(aenum.Enum):
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import aenum
|
import aenum
|
||||||
|
|
||||||
from socials_util import *
|
import socials_util
|
||||||
|
|
||||||
|
|
||||||
def test_extension():
|
def test_extension():
|
||||||
MY_SECRET_SITE = aenum.extend_enum(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
|
||||||
assert SocialSiteId.MY_SECRET_SITE
|
assert socials_util.SocialSiteId.MY_SECRET_SITE
|
||||||
|
|
||||||
REGEXES.append((r'test(\d+)', MY_SECRET_SITE))
|
socials_util.REGEXES.append((r'test(\d+)', my_secret_site))
|
||||||
|
|
||||||
url = 'test123'
|
url = 'test123'
|
||||||
result = determine_social_from_url(url)
|
result = socials_util.determine_social_from_url(url)
|
||||||
assert result is not None
|
assert result is not None
|
||||||
assert result.social_site_id == MY_SECRET_SITE
|
assert result.social_site_id == my_secret_site
|
||||||
assert result.social_id == '123'
|
assert result.social_id == '123'
|
||||||
|
|
|
@ -198,10 +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(url, expected_social_site_id, expected_social_id):
|
def test_parse_social_ids(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) == (
|
||||||
|
@ -211,5 +211,5 @@ def test_parse_social_ids(url, expected_social_site_id, expected_social_id):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('url', NOT_PARSABLE)
|
@pytest.mark.parametrize('url', NOT_PARSABLE)
|
||||||
def test_not_parsable(url: str):
|
def test_not_parsable(url: str) -> None:
|
||||||
assert determine_social_from_url(url) is None
|
assert determine_social_from_url(url) is None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user