File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 4
4
from sqlalchemy_utils import create_database , drop_database
5
5
from sqlalchemy import create_engine
6
6
7
+ from db .dbapi import DatabaseService
8
+
7
9
8
10
@pytest .fixture
9
11
def postgres ():
@@ -19,18 +21,30 @@ def postgres():
19
21
20
22
@pytest .fixture
21
23
def db_connection (postgres ):
22
- engine = create_engine (postgres )
24
+ engine = create_engine (postgres ,
25
+ pool_size = 10 ,
26
+ max_overflow = 2 ,
27
+ pool_recycle = 300 ,
28
+ pool_pre_ping = True ,
29
+ pool_use_lifo = True
30
+ )
23
31
conn = engine .connect ()
32
+ db = DatabaseService ()
24
33
try :
25
- yield conn
34
+ yield conn , db
26
35
finally :
27
36
conn .close ()
28
37
engine .dispose ()
29
38
30
39
31
40
@pytest .fixture
32
41
def fill_db (db_connection ):
33
- db_connection .execute (
42
+ db_connection [ 0 ] .execute (
34
43
"INSERT INTO users (name,hashed_password,lifetime) "
35
- f"VALUES ('existing_user', 'test', '{ datetime .now () + timedelta (minutes = 30 )} ')"
44
+ f"VALUES ('existing_user', '$2b$12$NlmobQnJ0.EMzOfJ9dZXfuj5lCl4RUuQdkC3MLAKPT/MRV2xJ2Qvi', "
45
+ f"'{ datetime .now () + timedelta (minutes = 30 )} ')"
36
46
)
47
+
48
+ db_connection [0 ].execute (f"""INSERT INTO tokens (token,expires_at,"user")
49
+ VALUES ('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiZXhpc3RpbmdfdXNlciJ9.9rgns-G5cW9RnadTqfxnmc8he3oGK7ytrsEkXRIAutU',
50
+ '{ datetime .now () + timedelta (minutes = 30 )} ','existing_user')""" )
You can’t perform that action at this time.
0 commit comments