diff --git a/nad_ch/application/use_cases.py b/nad_ch/application/use_cases.py index 43c8ce3..5c95062 100644 --- a/nad_ch/application/use_cases.py +++ b/nad_ch/application/use_cases.py @@ -74,6 +74,9 @@ def get_data_submission( ) -> DataSubmissionViewModel: submission = ctx.submissions.get_by_id(submission_id) + if submission is None: + return None + return get_view_model(submission) diff --git a/nad_ch/controllers/web/templates/reports/index.html b/nad_ch/controllers/web/templates/reports/index.html index 58c14dd..3926527 100644 --- a/nad_ch/controllers/web/templates/reports/index.html +++ b/nad_ch/controllers/web/templates/reports/index.html @@ -1,6 +1,7 @@ {% extends "_layouts/base.html" %} {% block title %}Home Page{% endblock %} {%block content %}
You haven't uploaded any data submissions yet.
+{% endif %} {% endblock %} diff --git a/nad_ch/controllers/web/templates/reports/show.html b/nad_ch/controllers/web/templates/reports/show.html index b7519aa..53805ab 100644 --- a/nad_ch/controllers/web/templates/reports/show.html +++ b/nad_ch/controllers/web/templates/reports/show.html @@ -1,4 +1,9 @@ {% extends "_layouts/base.html" %} {% block title %}Report{% endblock %} {%block content %}{{ submission.filename }}
+{{ submission.date_created}}
+{% else %} +No such submission exists.
+{% endif %} {% endblock %} diff --git a/tests/controllers/__init__.py b/tests/controllers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/controllers/test_web.py b/tests/controllers/test_web.py new file mode 100644 index 0000000..90dd72c --- /dev/null +++ b/tests/controllers/test_web.py @@ -0,0 +1,34 @@ +import pytest +from nad_ch.config import create_app_context +from nad_ch.controllers.web.flask import create_flask_application + + +@pytest.fixture +def app(): + context = create_app_context() + app = create_flask_application(context) + yield app + + +@pytest.fixture +def client(app): + return app.test_client() + + +def test_home_route(client): + response = client.get("/") + assert response.status_code == 200 + assert "Welcome" in response.data.decode("utf-8") + + +def test_reports_route(client): + response = client.get("/reports") + assert response.status_code == 200 + assert "Reports" in response.data.decode("utf-8") + + +def test_view_report_route(client): + submission_id = "some_valid_id" + response = client.get(f"/reports/{submission_id}") + assert response.status_code == 200 + assert "Report" in response.data.decode("utf-8")