Delete testing user afer unit test session

This commit is contained in:
2021-01-06 21:46:29 +01:00
parent 6c7a561fef
commit 71517bb8b2
4 changed files with 23 additions and 19 deletions

14
tests/conftest.py Normal file
View File

@@ -0,0 +1,14 @@
from pytest import fixture
from database.crud import delete_data
from tests import TestingSessionLocal
@fixture(scope="session")
def get_test_db():
try:
db = TestingSessionLocal()
yield db
finally:
delete_data(model="Users", data=2222, db=db)
db.close()

View File

@@ -1,18 +1,6 @@
from datetime import datetime
from pytest import fixture
from database.models import *
from tests import TestingSessionLocal
@fixture
def get_test_db():
try:
db = TestingSessionLocal()
yield db
finally:
db.close()
def test_users(get_test_db):

View File

@@ -1,10 +1,10 @@
from secrets import token_hex
from pytest import main
from app.schemas import *
from database.models import *
from tests import client
from tests.queries_test import get_test_db
def test_registration():
@@ -55,8 +55,8 @@ def test_forgot_password():
assert response.status_code == 200
def test_reset_password():
main(["-k" "test_otp_verification"])
def test_reset_password(get_test_db):
test_otp_verification(get_test_db)
data = {"email": "oyvey@hotmail.com", "password": "vivashviva"}
response = client.post("/reset_password", json=data)
assert response.status_code == 200