mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-18 13:47:11 +00:00
Now using HTTP status codes properly
This commit is contained in:
@@ -3,6 +3,7 @@ Modified for Expo April 2021.
|
||||
"""
|
||||
|
||||
import re
|
||||
from http import HTTPStatus
|
||||
|
||||
from django.test import Client, TestCase
|
||||
|
||||
@@ -65,7 +66,7 @@ class FixtureTests(TestCase):
|
||||
content = response.content.decode()
|
||||
# with open('testresponse.html','w') as tr:
|
||||
# tr.writelines(content)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
for ph in [r"Michael Sargent", r"Table of all trips and surveys aligned by date"]:
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
||||
@@ -98,7 +99,7 @@ class FixturePageTests(TestCase):
|
||||
|
||||
def test_fix_expedition(self):
|
||||
response = self.client.get("/expedition/2019")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
ph = r"Michael Sargent"
|
||||
|
||||
@@ -110,7 +111,7 @@ class FixturePageTests(TestCase):
|
||||
|
||||
def test_fix_personexped(self):
|
||||
response = self.client.get("/personexpedition/MichaelSargent/2019")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
ph = r"Table of all trips and surveys aligned by date"
|
||||
|
||||
@@ -122,7 +123,7 @@ class FixturePageTests(TestCase):
|
||||
|
||||
def test_fix_person(self):
|
||||
response = self.client.get("/person/MichaelSargent")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
ph = r"second-generation expo caver "
|
||||
|
||||
@@ -135,7 +136,7 @@ class FixturePageTests(TestCase):
|
||||
def test_fix_cave_url115(self):
|
||||
ph = self.ph
|
||||
response = self.client.get("/1623/115.url") # yes this is intentional, see the inserted data above & fixture
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
content = response.content.decode()
|
||||
phmatch = re.search(ph, content)
|
||||
@@ -143,7 +144,7 @@ class FixturePageTests(TestCase):
|
||||
|
||||
def test_fix_cave_url284(self):
|
||||
response = self.client.get("/1623/284/284.html")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
|
||||
ph = r"at a depth of 72m, there are large round blocks"
|
||||
|
||||
@@ -158,7 +159,7 @@ class FixturePageTests(TestCase):
|
||||
ph = self.ph
|
||||
ph = "Probably a mistake."
|
||||
response = self.client.get("/1623/115")
|
||||
self.assertEqual(response.status_code, 404)
|
||||
self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)
|
||||
|
||||
content = response.content.decode()
|
||||
phmatch = re.search(ph, content)
|
||||
@@ -169,7 +170,7 @@ class FixturePageTests(TestCase):
|
||||
ph = self.ph
|
||||
ph = "Probably a mistake."
|
||||
response = self.client.get("/1623-115")
|
||||
self.assertEqual(response.status_code, 404)
|
||||
self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)
|
||||
|
||||
content = response.content.decode()
|
||||
phmatch = re.search(ph, content)
|
||||
|
||||
Reference in New Issue
Block a user