diff --git a/test/test_base.py b/test/test_base.py index 9c8f1d9b..185cc376 100644 --- a/test/test_base.py +++ b/test/test_base.py @@ -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 diff --git a/test/test_database_helpers.py b/test/test_database_helpers.py index d7ee2173..bdbfd1be 100644 --- a/test/test_database_helpers.py +++ b/test/test_database_helpers.py @@ -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( diff --git a/test/test_entityHelper.py b/test/test_entityHelper.py index 780bc2d7..a2e9c224 100644 --- a/test/test_entityHelper.py +++ b/test/test_entityHelper.py @@ -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() diff --git a/test/test_helpers.py b/test/test_helpers.py index ce4d517b..04cc653e 100644 --- a/test/test_helpers.py +++ b/test/test_helpers.py @@ -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("[]")) @@ -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() @@ -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 @@ -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: @@ -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: