feat: add parser functions with tests
This commit is contained in:
24
tests/test_parsers.py
Normal file
24
tests/test_parsers.py
Normal 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"
|
||||
Reference in New Issue
Block a user