edh-elo/tests/routers/test_seed.py
Jack Jackson 9b4e6c3b4d
All checks were successful
Publish / build-and-push (push) Successful in 6m14s
Introduce ability to seed data directly from GSheet
Reasonably hacky, in that I introduce a facade to reuse the data format
previously provided by the `csv` module, rather than using the
`list[list[str]]` directly.

Next I want to introduce something like Celery to continually refresh.

Note that this will require changes to the deployment repo in order to
provide the required secrets.
2025-04-17 22:22:21 -07:00

16 lines
565 B
Python

# A test for the hacky workaround class I made that imitates the CSV-reader-interface when passed a list[list[str]]
# as we get from the Google Sheets API
from app.routers.seed import CSVFacade
def test_csv_facade():
facade = CSVFacade([["a", "b", "c"], ["1", "2", "3"], ["4", "5", "6"]])
for i, row in enumerate(facade):
if i == 0:
assert row == {"a": "1", "b": "2", "c": "3"}
elif i == 1:
assert row == {"a": "4", "b": "5", "c": "6"}
else:
raise ValueError(f"Expected 2 rows, but got {i+1}")