#11 Starting on the creation of an end to end test environment
This commit is contained in:
parent
d056146a44
commit
bcde471f33
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@ -38,6 +38,11 @@ def create_connection(path: str, filename: str):
|
|||||||
|
|
||||||
|
|
||||||
# Ensure a directory is created given a path to it
|
# Ensure a directory is created given a path to it
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run()
|
||||||
|
|
||||||
|
def run():
|
||||||
|
""" Create the database for the application"""
|
||||||
dir = r"./data/"
|
dir = r"./data/"
|
||||||
db_name = r"wmgzon.db"
|
db_name = r"wmgzon.db"
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
|
import pytest
|
||||||
import os
|
import os
|
||||||
|
from scripts.create_database import run
|
||||||
|
from app import app
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from flask.testing import FlaskClient
|
||||||
|
|
||||||
|
|
||||||
# Setup test environment variables
|
# Setup test environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@ -8,3 +13,15 @@ load_dotenv()
|
|||||||
# Monitor current setting during tests
|
# Monitor current setting during tests
|
||||||
old_env = os.environ.get("ENVIRON")
|
old_env = os.environ.get("ENVIRON")
|
||||||
os.environ["ENVIRON"] = "test"
|
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
|
||||||
|
0
tests/endtoend/__init__.py
Normal file
0
tests/endtoend/__init__.py
Normal file
8
tests/endtoend/use_cases_test.py
Normal file
8
tests/endtoend/use_cases_test.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import pytest
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from tests import test_client
|
||||||
|
from flask.testing import FlaskClient
|
||||||
|
|
||||||
|
# def test_use_case(test_client: FlaskClient):
|
||||||
|
# response = test_client.get('/products/Car Parts')
|
||||||
|
# assert response.status_code == 200
|
@ -1,16 +0,0 @@
|
|||||||
from app import app
|
|
||||||
from flask.testing import FlaskClient
|
|
||||||
import pytest
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def test_client() -> FlaskClient:
|
|
||||||
""" Test that required environment variables are set
|
|
||||||
ahead of runtime
|
|
||||||
"""
|
|
||||||
os.environ['CONFIG_TYPE'] = 'config.TestingConfig'
|
|
||||||
|
|
||||||
with app.test_client() as testing_client:
|
|
||||||
with app.app_context():
|
|
||||||
yield testing_client
|
|
@ -1,5 +1,5 @@
|
|||||||
from flask.testing import FlaskClient
|
from flask.testing import FlaskClient
|
||||||
from tests.functional import test_client
|
from tests import test_client
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
# Ensure test environment is set before using
|
# Ensure test environment is set before using
|
||||||
# Runs the database creation scripts
|
# Runs the database creation scripts
|
||||||
import scripts.create_database
|
|
||||||
|
Loading…
Reference in New Issue
Block a user