Add simple tests against the project using IPv4 and IPv6
This commit is contained in:
parent
0262782844
commit
aa9aaad78c
2 changed files with 30 additions and 0 deletions
|
@ -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.
|
||||
|
|
22
tests.py
Normal file
22
tests.py
Normal file
|
@ -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
|
||||
)
|
Loading…
Reference in a new issue