Private
Public Access
1
0

feat: add parser functions with tests

This commit is contained in:
belisards
2026-03-29 16:52:40 -03:00
parent c5a01190c1
commit cdd71deb17
4 changed files with 77 additions and 0 deletions

0
tests/__init__.py Normal file
View File

24
tests/test_parsers.py Normal file
View File

@@ -0,0 +1,24 @@
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from scraper import extract_hashtags, extract_mentions, profile_slug_from_url
def test_extract_hashtags_basic():
assert extract_hashtags("Hello #world #foo") == ["#world", "#foo"]
def test_extract_hashtags_empty():
assert extract_hashtags("No tags here") == []
def test_extract_hashtags_deduplicates():
assert extract_hashtags("#foo #foo #bar") == ["#foo", "#bar"]
def test_extract_mentions_basic():
assert extract_mentions("Hey @alice and @bob") == ["@alice", "@bob"]
def test_extract_mentions_empty():
assert extract_mentions("No mentions") == []
def test_profile_slug_from_url():
assert profile_slug_from_url("https://www.instagram.com/licmuunisul/") == "licmuunisul"
def test_profile_slug_trailing_slash():
assert profile_slug_from_url("https://www.instagram.com/licmuunisul") == "licmuunisul"