From 077ae93d8939388fca560924f88e05209e83d622 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Tue, 30 Jan 2024 19:30:02 +0000 Subject: [PATCH] CHORE: Updated tests to better check env vars --- static/css/products.css | 4 ++-- tests/__init__.py | 7 +++++-- tests/database/test_products.py | 2 +- tests/general/test_env.py | 7 +++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/static/css/products.css b/static/css/products.css index 81144a4..f867c01 100644 --- a/static/css/products.css +++ b/static/css/products.css @@ -53,12 +53,12 @@ .product-fs { height: 80%; - width: 80%; + width: 90%; font-size: 150%; display: flex; flex-direction: row; - justify-content: space-between; gap: 1em 1em; + justify-content: space-evenly; padding: .5rem 1rem 2rem 2rem; /* background: var(--bg-secondary); */ border-radius: .5rem .5rem; diff --git a/tests/__init__.py b/tests/__init__.py index 2005eed..79b9107 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,8 @@ import os # Setup test environment variables -if os.environ.get("ENVIRON") is None: - os.environ["ENVIRON"] = "test" + +# Capture environment variables at start of testing so we can +# Monitor current setting during tests +old_env = os.environ.get("ENVIRON") +os.environ["ENVIRON"] = "test" diff --git a/tests/database/test_products.py b/tests/database/test_products.py index 6c3870a..0b7c69e 100644 --- a/tests/database/test_products.py +++ b/tests/database/test_products.py @@ -6,7 +6,7 @@ from models.products.product import Product product = Product( "product", - "brake-disk.bmp", + "brake-disks.bmp", "description", 10.00, 1, diff --git a/tests/general/test_env.py b/tests/general/test_env.py index ea89775..3ca13d5 100644 --- a/tests/general/test_env.py +++ b/tests/general/test_env.py @@ -1,11 +1,14 @@ from os import environ from warnings import warn +from tests import old_env # Tests environment variables used within the projects domain are # set in the correct environment VARS = ['ENVIRON', 'APPSECRET', 'FILESTORE'] +ENV_STATES = ['test', 'prod'] + def test_env_vars(): """ Test that required environment variables are set @@ -23,6 +26,6 @@ def test_environment_var_state(): """ Tests that the 'ENVIRON' Environment variable is in a correct state """ - var = environ.get('ENVIRON') + var = old_env assert var is not None - assert (var == "test" or var == "prod") + assert (var in ENV_STATES)