hellocomputer/test/test_data.py

27 lines
702 B
Python
Raw Normal View History

2024-05-21 21:50:17 +02:00
import hellocomputer
from hellocomputer.analytics import DDB
from pathlib import Path
TEST_DATA_FOLDER = Path(hellocomputer.__file__).parents[2] / "test" / "data"
TEST_OUTPUT_FOLDER = Path(hellocomputer.__file__).parents[2] / "test" / "output"
2024-05-21 22:11:47 +02:00
def test_dump():
2024-05-21 21:50:17 +02:00
db = (
DDB()
.load_metadata(TEST_DATA_FOLDER / "TestExcelHelloComputer.xlsx")
.dump_local(TEST_OUTPUT_FOLDER)
)
assert db.sheets == ("answers",)
assert (TEST_OUTPUT_FOLDER / "answers.csv").exists()
2024-05-21 22:11:47 +02:00
def test_load():
db = DDB().load_folder_local(TEST_OUTPUT_FOLDER)
2024-05-23 18:12:27 +02:00
results = db.query("select * from answers").fetchall()
2024-05-21 22:11:47 +02:00
assert db.sheets == ("answers",)
2024-05-23 18:12:27 +02:00
assert len(results) == 2