Delete testing user afer unit test session
This commit is contained in:
14
tests/conftest.py
Normal file
14
tests/conftest.py
Normal 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()
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user