simplify repo and added some tests

This commit is contained in:
fabianegli 2024-10-19 13:06:34 +02:00
parent 6bb598820e
commit 0c05461f84
11 changed files with 527 additions and 181 deletions

21
code/tests.py Normal file
View file

@ -0,0 +1,21 @@
"""These tests can be run with pytest.
This requires pytest: pip install pytest
cd to the `code` directory and run `pytest`
"""
import json
from pathlib import Path
from dark_visitors import json_to_txt, json_to_table
def test_robots_txt_creation():
robots_json = json.loads(Path("test_files/robots.json").read_text())
robots_txt = json_to_txt(robots_json)
assert Path("test_files/robots.txt").read_text() == robots_txt
def test_table_of_bot_metrices_md():
robots_json = json.loads(Path("test_files/robots.json").read_text())
robots_table = json_to_table(robots_json)
assert Path("test_files/table-of-bot-metrics.md").read_text() == robots_table