Skip to content

Commit

Permalink
#150: Work out how the existing tests will work with the new test st…
Browse files Browse the repository at this point in the history
…ructure

- Just a few comments to help me work out what to do with the existing tests for DB backend. These will be moved to work with Pytest once the new test structure has been defined
  • Loading branch information
MRichards99 committed Sep 28, 2020
1 parent 0760556 commit db43d3d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from src.main import app


# Move this into the test defintions and let it be inherited in test classes that need
# it
class FlaskAppTest(TestCase):
"""
The FlaskAppTest Base class sets up a test client to be used to mock requests
Expand Down
3 changes: 2 additions & 1 deletion test/test_database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
" has a valid backend type"
)


# Common across both, needs parameterized tests for different cased names, need multiple
# tests for each filter
class TestQueryFilterFactory(TestCase):
def test_order_filter(self):
self.assertIs(
Expand Down
1 change: 1 addition & 0 deletions test/test_entityHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from common.models.db_models import DATAFILE, DATASET, DATAFILEFORMAT, INVESTIGATION


# DB only tests
class TestEntityHelper(TestCase):
def setUp(self):
self.dataset = DATASET()
Expand Down
7 changes: 5 additions & 2 deletions test/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from test.test_base import FlaskAppTest


# Put this in test definitions, but do tests there, don't abstract out
class TestIs_valid_json(TestCase):
def test_array(self):
self.assertTrue(is_valid_json("[]"))
Expand All @@ -55,6 +56,7 @@ def test_list(self):
self.assertFalse(is_valid_json([]))


# Common for both backends, setup and teardown will be different
class TestRequires_session_id(FlaskAppTest):
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -93,7 +95,7 @@ def test_good_credentials(self):
).status_code,
)


# Common across both, no need to abstract out
class TestQueries_records(TestCase):
def test_missing_record_error(self):
@queries_records
Expand Down Expand Up @@ -161,6 +163,7 @@ def raise_bad_request_error():
self.assertEqual(400, ctx.exception.status_code)


# Common across both, no need to abstract out
class TestGet_session_id_from_auth_header(FlaskAppTest):
def test_no_session_in_header(self):
with self.app:
Expand All @@ -177,7 +180,7 @@ def test_with_good_header(self):
self.app.get("/", headers={"Authorization": "Bearer test"})
self.assertEqual("test", get_session_id_from_auth_header())


# Common across both, needs abstracting out, class per filter, multiple tests per filter
class TestGet_filters_from_query_string(FlaskAppTest):
def test_no_filters(self):
with self.app:
Expand Down

0 comments on commit db43d3d

Please sign in to comment.