aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests/base
diff options
context:
space:
mode:
authorBonfaceKilz2020-09-28 18:34:53 +0300
committerBonfaceKilz2020-09-28 18:35:58 +0300
commit21ec6863d7f8380d66c39f1ed3b8d9cc0dc86e49 (patch)
treead0074a24087b8410c0b58c671038b6e6ced3cd9 /wqflask/tests/base
parentda6098574f8b410386e84f07fd0e8d0eed39e40d (diff)
downloadgenenetwork2-21ec6863d7f8380d66c39f1ed3b8d9cc0dc86e49.tar.gz
Fix failing test
* wqflask/tests/base/test_trait.py: Add app_context to test class, otherwise an error related to working outside the app_context is generated. Adding the app_context is required when mocking "Flask.g".
Diffstat (limited to 'wqflask/tests/base')
-rw-r--r--wqflask/tests/base/test_trait.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/wqflask/tests/base/test_trait.py b/wqflask/tests/base/test_trait.py
index 60ebaee0..826ccefd 100644
--- a/wqflask/tests/base/test_trait.py
+++ b/wqflask/tests/base/test_trait.py
@@ -3,6 +3,7 @@
import unittest
from unittest import mock
+from wqflask import app
from base.trait import GeneralTrait
from base.trait import retrieve_trait_info
@@ -31,6 +32,14 @@ class MockTrait(GeneralTrait):
class TestRetrieveTraitInfo(unittest.TestCase):
"""Tests for 'retrieve_trait_info'"""
+
+ def setUp(self):
+ self.app_context = app.app_context()
+ self.app_context.push()
+
+ def tearDown(self):
+ self.app_context.pop()
+
def test_retrieve_trait_info_with_empty_dataset(self):
"""Test that an exception is raised when dataset is empty"""
with self.assertRaises(AssertionError):
@@ -104,7 +113,7 @@ class TestRetrieveTraitInfo(unittest.TestCase):
resource_id_mock,
g_mock,
requests_mock):
- """Test """
+ """Test retrieve trait info when lrs has a value"""
resource_id_mock.return_value = 1
g_mock.db.execute.return_value.fetchone = mock.Mock()
g_mock.db.execute.return_value.fetchone.side_effect = [