From aa54319778d901e71f56b66a4d4e42cc25da03bc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 13 Apr 2020 10:50:59 +0100 Subject: [PATCH] Add basic homepage test --- scripts/test.sh | 5 ++++- setup.cfg | 3 --- website/common/tests.py | 12 ++++++++++++ website/common/urls.py | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 website/common/tests.py diff --git a/scripts/test.sh b/scripts/test.sh index 9331707..ffc978c 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -4,7 +4,10 @@ set -e export PATH=env/bin:${PATH} -coverage run manage.py test $@ +coverage run --source=website manage.py test $@ + +coverage report +coverage html echo "> Running formatter..." black website/ --check diff --git a/setup.cfg b/setup.cfg index 2f86b76..e9892c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,3 @@ force_grid_wrap=0 use_parentheses=True line_length=88 not_skip=__init__.py - -[coverage:run] -source = "website" diff --git a/website/common/tests.py b/website/common/tests.py new file mode 100644 index 0000000..de1c2ef --- /dev/null +++ b/website/common/tests.py @@ -0,0 +1,12 @@ +from django.test import SimpleTestCase +from django.urls import reverse + + +class BaseTestCase(SimpleTestCase): + pass + + +class HomepageViewTestCase(BaseTestCase): + def test_accessible(self): + response = self.client.get(reverse("homepage")) + self.assertEqual(response.status_code, 200) diff --git a/website/common/urls.py b/website/common/urls.py index eb1dae5..78031a6 100644 --- a/website/common/urls.py +++ b/website/common/urls.py @@ -2,4 +2,4 @@ from django.urls import path from . import views -urlpatterns = [path("", views.HomepageView.as_view())] +urlpatterns = [path("", views.HomepageView.as_view(), name="homepage")]