28 lines
657 B
Python
28 lines
657 B
Python
import inspect
|
|
import json
|
|
import os
|
|
from recipe_graph import insert_sites
|
|
from sqlalchemy import select
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
import sqlalchemy
|
|
|
|
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 |