2024-11-01 20:42:16 +00:00
|
|
|
import pytest
|
2023-12-19 22:08:54 +00:00
|
|
|
import aenum
|
|
|
|
|
2024-10-20 17:38:14 +00:00
|
|
|
import socials_util
|
2024-05-12 14:35:17 +00:00
|
|
|
|
2024-11-01 20:42:16 +00:00
|
|
|
def test_re_social_path_validation():
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
socials_util.re_social_path('www.example.org')
|
|
|
|
|
2024-03-31 22:37:15 +00:00
|
|
|
|
2023-12-19 22:08:54 +00:00
|
|
|
def test_extension():
|
2024-10-20 17:38:14 +00:00
|
|
|
my_secret_site = aenum.extend_enum(socials_util.SocialSiteId, 'MY_SECRET_SITE', 666)
|
|
|
|
assert my_secret_site
|
|
|
|
assert socials_util.SocialSiteId.MY_SECRET_SITE
|
2023-12-19 22:08:54 +00:00
|
|
|
|
2024-10-20 17:38:14 +00:00
|
|
|
socials_util.REGEXES.append((r'test(\d+)', my_secret_site))
|
2023-12-22 00:19:09 +00:00
|
|
|
|
|
|
|
url = 'test123'
|
2024-10-20 17:38:14 +00:00
|
|
|
result = socials_util.determine_social_from_url(url)
|
2023-12-22 00:19:09 +00:00
|
|
|
assert result is not None
|
2024-10-20 17:38:14 +00:00
|
|
|
assert result.social_site_id == my_secret_site
|
2023-12-22 00:19:09 +00:00
|
|
|
assert result.social_id == '123'
|