aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_db_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test_db_utils.py')
-rw-r--r--tests/unit/test_db_utils.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/unit/test_db_utils.py b/tests/unit/test_db_utils.py
index 68f80a0..a319692 100644
--- a/tests/unit/test_db_utils.py
+++ b/tests/unit/test_db_utils.py
@@ -6,9 +6,14 @@ from types import SimpleNamespace
import pytest
+import gn3
from gn3.db_utils import database_connector
from gn3.db_utils import parse_db_url
+@pytest.fixture(scope="class")
+def setup_app(request, fxtr_app):
+ """Setup the fixtures for the class."""
+ request.cls.app = fxtr_app
class TestDatabase(TestCase):
"""class contains testd for db connection functions"""
@@ -31,10 +36,14 @@ class TestDatabase(TestCase):
results, SimpleNamespace, "database not created successfully")
@pytest.mark.unit_test
- @mock.patch("gn3.db_utils.SQL_URI",
- "mysql://username:4321@localhost/test")
+ @pytest.mark.usefixtures("setup_app")
def test_parse_db_url(self):
"""test for parsing db_uri env variable"""
- results = parse_db_url()
- expected_results = ("localhost", "username", "4321", "test", None)
- self.assertEqual(results, expected_results)
+ print(self.__dict__)
+ with self.app.app_context(), mock.patch.dict(# pylint: disable=[no-member]
+ gn3.db_utils.current_app.config,
+ {"SQL_URI": "mysql://username:4321@localhost/test"},
+ clear=True):
+ results = parse_db_url()
+ expected_results = ("localhost", "username", "4321", "test", None)
+ self.assertEqual(results, expected_results)