diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 48dfd4f..2fabf19 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,13 @@ ## Development Environment FAQ +### How to run tests? + +From the project root directory, execute the following command: + +```sh +python ./manage.py test +``` + ### How to maintain `requirements.txt`? The canonical list of installation requirements (including development requirements) is maintained in the [`setup.py`](setup.py) file. diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..34bb236 --- /dev/null +++ b/tests.py @@ -0,0 +1,22 @@ +from django.urls import reverse +from django.test import Client, TestCase + + +class UngleichScreeningTaskTests(TestCase): + def setUp(self): + self.ipv4_client = Client(REMOTE_ADDR="127.0.0.1") + self.ipv6_client = Client(REMOTE_ADDR="::1") + + def test_project_using_ipv4(self): + url = reverse("index") + response = self.ipv4_client.get(url) + self.assertContains( + response, "Sorry, only reachable by IPv6", status_code=400, html=True + ) + + def test_project_using_ipv6(self): + url = reverse("index") + response = self.ipv6_client.get(url) + self.assertContains( + response, "A friendly cat picture", status_code=200, html=True + )