added test for loading json file
This commit is contained in:
parent
6189de8039
commit
9b9e629548
|
|
@ -1,7 +1,28 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
import json
|
||||||
|
import os
|
||||||
from recipe_graph import insert_sites
|
from recipe_graph import insert_sites
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.exc import SQLAlchemyError
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def json_data() -> list[dict]:
|
||||||
|
return [{"key": "value"}, {"test": "value1", "test2": "value2"}]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def json_file(json_data: list[dict]) -> str:
|
||||||
|
f_path = "test.json"
|
||||||
|
with open(f_path, 'w') as f:
|
||||||
|
json.dump(json_data, f)
|
||||||
|
yield f_path
|
||||||
|
if os.path.exists(f_path):
|
||||||
|
os.remove(f_path)
|
||||||
|
|
||||||
|
def test_load_file(json_file: str, json_data):
|
||||||
|
test_data = insert_sites.load_file(json_file)
|
||||||
|
assert test_data == json_data
|
||||||
Loading…
Reference in New Issue