#11 Starting on the creation of an end to end test environment

This commit is contained in:
2024-02-23 18:24:57 +00:00
parent d056146a44
commit bcde471f33
8 changed files with 41 additions and 28 deletions

View File

@@ -1,5 +1,10 @@
import pytest
import os
from scripts.create_database import run
from app import app
from dotenv import load_dotenv
from flask.testing import FlaskClient
# Setup test environment variables
load_dotenv()
@@ -8,3 +13,15 @@ load_dotenv()
# Monitor current setting during tests
old_env = os.environ.get("ENVIRON")
os.environ["ENVIRON"] = "test"
run()
@pytest.fixture(scope="module")
def test_client() -> FlaskClient:
""" Enables tests to create requests to the web app
"""
os.environ['CONFIG_TYPE'] = 'config.TestingConfig'
with app.test_client() as testing_client:
with app.app_context():
yield testing_client