11"""Shared pytest fixtures."""
22
33import json
4+ import logging
45import os
56from pathlib import Path
67
1011from sqlalchemy .orm import Session , sessionmaker
1112from testcontainers .postgres import PostgresContainer
1213
13- from ttfd import abomination , crud
14+ from ttfd import abomination , crud , reactions
1415from ttfd .deps import get_db
1516from ttfd .main import app
16- from ttfd .models import Base
17+ from ttfd .models import Base , Reaction
18+
19+ logger = logging .getLogger (__name__ )
1720
1821
1922@pytest .fixture (scope = "session" )
@@ -35,6 +38,7 @@ def database(setup_postgres):
3538 # 2. Find all metabolites referenced by those and add dummies
3639 metabolites = json .loads (Path ("test/metabolites-test-generated.json" ).read_text ())
3740 paths = json .loads (Path ("test/paths-test-generated.json" ).read_text ())
41+ reactions = json .loads (Path ("test/reactions-test-generated.json" ).read_text ())
3842 # 3.
3943 session_factory = sessionmaker (
4044 bind = engine ,
@@ -60,6 +64,19 @@ def database(setup_postgres):
6064 categories = [],
6165 )
6266
67+ for reaction , instances in reactions .items ():
68+ for num , instance in enumerate (instances ):
69+ crud .insert_reaction (
70+ session ,
71+ reaction ,
72+ None ,
73+ num ,
74+ None ,
75+ [],
76+ instance ["left" ],
77+ instance ["right" ],
78+ )
79+
6380 for path in paths :
6481 rp , met , br , lo , p = path .split ("\n " )
6582 lp = abomination .LabelingPath (
@@ -125,6 +142,7 @@ def regression_database(setup_postgres):
125142@pytest .fixture
126143def test_client (database : Session ):
127144 """Provide a http client to access the app in a test environment."""
145+
128146 def get_db_override ():
129147 return database
130148
0 commit comments