1
0

Code quality
Some checks are pending
Python Ruff Code Quality / ruff (push) Waiting to run
Run Python tests (through Pytest) / Test (push) Waiting to run
Verify Python project can be installed, loaded and have version checked / Test (push) Waiting to run

This commit is contained in:
Jon Michael Aanes 2024-10-20 19:38:14 +02:00
parent 4ea9d71f53
commit 1396391fbb
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 13 additions and 11 deletions

View File

@ -12,7 +12,9 @@ from dataclasses import dataclass
import aenum
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):

View File

@ -1,17 +1,17 @@
import aenum
from socials_util import *
import socials_util
def test_extension():
MY_SECRET_SITE = aenum.extend_enum(SocialSiteId, 'MY_SECRET_SITE', 666)
assert MY_SECRET_SITE
assert SocialSiteId.MY_SECRET_SITE
my_secret_site = aenum.extend_enum(socials_util.SocialSiteId, 'MY_SECRET_SITE', 666)
assert 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'
result = determine_social_from_url(url)
result = socials_util.determine_social_from_url(url)
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'

View File

@ -198,10 +198,10 @@ NOT_PARSABLE = [
@pytest.mark.parametrize(
'url,expected_social_site_id,expected_social_id',
('url','expected_social_site_id','expected_social_id'),
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)
assert social_link is not None, url
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)
def test_not_parsable(url: str):
def test_not_parsable(url: str) -> None:
assert determine_social_from_url(url) is None