diff options
author | Frederick Muriuki Muriithi | 2024-02-28 11:32:26 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-02-28 11:32:26 +0300 |
commit | 77eeaec1ecdef5f110c69aa767969649e353b22b (patch) | |
tree | 295f88ab71f54489d905acbe95b06cce86edd7d9 | |
parent | 9ab4316ee3c4d3068053c94334c64915514d8664 (diff) | |
download | gn-uploader-77eeaec1ecdef5f110c69aa767969649e353b22b.tar.gz |
tests: test with just the message - don't include markup
Markup can, and will change as improvements are made, but the error
messages will not change that often, plus that is what we want to
actually test for, not the markup.
-rw-r--r-- | README.org | 2 | ||||
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/qc_app/test_entry.py | 16 |
3 files changed, 7 insertions, 13 deletions
@@ -218,7 +218,7 @@ To check for correct type usage in the application, run: Run unit tests with: #+BEGIN_SRC shell $ export QCAPP_CONF=</path/to/configuration/file.py> - $ pytest -k unit_test + $ pytest -m unit_test #+END_SRC To run ALL tests (not just unit tests): diff --git a/tests/conftest.py b/tests/conftest.py index 013c30d..e4bebc6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -46,7 +46,7 @@ def cleanup_redis(redisuri: str, prefix: str): @pytest.fixture(scope="module") def client(): "Fixture for test client" - app = create_app(os.environ.get("QCAPP_INSTANCE_PATH")) + app = create_app() test_prefix = sha256(f"test:{uuid.uuid4()}".encode("utf8")).hexdigest() app.config.update({ "TESTING": True, diff --git a/tests/qc_app/test_entry.py b/tests/qc_app/test_entry.py index efc72a5..bfe56ec 100644 --- a/tests/qc_app/test_entry.py +++ b/tests/qc_app/test_entry.py @@ -37,12 +37,8 @@ def test_post_notifies_errors_if_no_data_is_provided(client): """ response = client.post("/", data={}) assert response.status_code == 400 - assert ( - b'<span class="alert alert-error">Invalid file type provided.</span>' - in response.data) - assert ( - b'<span class="alert alert-error">No file was uploaded.</span>' - in response.data) + assert b'Invalid file type provided.' in response.data + assert b'No file was uploaded.' in response.data def test_post_with_correct_data(client): """ @@ -69,11 +65,9 @@ def test_post_with_correct_data(client): "request_data,error_message", (({"filetype": "invalid_choice", "qc_text_file": uploadable_file_object("no_data_errors.tsv")}, - b'<span class="alert alert-error">Invalid file type provided.</span>'), - ({"filetype": "average"}, - b'<span class="alert alert-error">No file was uploaded.</span>'), - ({"filetype": "standard-error"}, - b'<span class="alert alert-error">No file was uploaded.</span>'))) + b'Invalid file type provided.'), + ({"filetype": "average"}, b'No file was uploaded.'), + ({"filetype": "standard-error"}, b'No file was uploaded.'))) def test_post_with_missing_or_invalid_data(client, request_data,error_message): """ GIVEN: A flask application testing client |