added tests, changed __main__ to cli

This commit is contained in:
Tristan Lee
2023-09-04 13:26:38 -05:00
parent 0f8e865bf3
commit 5ae9624968
11 changed files with 101 additions and 3 deletions

15
tests/base.py Normal file
View File

@@ -0,0 +1,15 @@
from tiktok_hashtag_analysis.base import TikTokDownloader, load_hashtags_from_file
def test_scrape(tmp_path, hashtags):
downloader = TikTokDownloader(hashtags=hashtags[:1], data_dir=tmp_path)
downloader.run(download=True, plot=True, table=True, number=20)
def test_load_hashtags_from_file(tmp_path, hashtags):
file = tmp_path / "hashtags.txt"
with open(file, "w", encoding="utf-8") as f:
f.write("\n".join(hashtags))
loaded_hashtags = load_hashtags_from_file(file=file)
assert loaded_hashtags == hashtags