Initial commit
This commit is contained in:
30
tests/test_figures.py
Normal file
30
tests/test_figures.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
import os
|
||||
from dataclasses import asdict
|
||||
|
||||
import pytest
|
||||
|
||||
from hpoi.models.figure import Figure
|
||||
from hpoi.models.tag import Tag
|
||||
|
||||
|
||||
async def common_figure_test(hpoi_id):
|
||||
figure = await Figure.from_hpoi_id(hpoi_id)
|
||||
assert figure is not None
|
||||
assert isinstance(figure, Figure)
|
||||
return figure
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_figures():
|
||||
with open(
|
||||
os.path.join(os.path.dirname(__file__), "test_data/figures.json")
|
||||
) as file:
|
||||
test_cases: list[dict] = json.load(file)["figures"]
|
||||
|
||||
for test_case in test_cases:
|
||||
figure_test_case = Figure(**test_case)
|
||||
figure_hpoi = asdict(await Figure.from_hpoi_id(figure_test_case.hpoi_id))
|
||||
|
||||
for parameter, value in test_case.items():
|
||||
assert value == figure_hpoi[parameter]
|
Reference in New Issue
Block a user