irongit

Enhanced time synchronization for drf views.

added test to see if the should_update would use raise_exception config

huncholanehuncholaneauthored
parent a6d7be6commit 548a58ed04fc65b2b136552ba880541bba04ebccBrowse files

1 file changed, +12 -0

+12-0timecheck/tests.py
@@ -29,15 +29,18 @@ class TimeCheckTests(TestCase):
2929 def test_get_client_is_older(self):
3030 client_time = fmt_dt(self.earlier)
3131 response = self.client.get("/", HTTP_LASTUPDATED=client_time)
32+ conf["raise_exception"] = True
3233 self.assertEqual(response.status_code, 200)
3334
3435 def test_get_client_is_equal(self):
3536 client_time = fmt_dt(self.now)
3637 response = self.client.get("/", HTTP_LASTUPDATED=client_time)
38+ conf["raise_exception"] = True
3739 self.assertEqual(response.status_code, conf["noupdate_code"])
3840
3941 def test_put_client_is_newer(self):
4042 client_time = fmt_dt(self.later)
43+ conf["raise_exception"] = True
4144 response = self.client.put(
4245 "/",
4346 {
@@ -50,15 +53,24 @@ class TimeCheckTests(TestCase):
5053
5154 def test_put_client_is_older(self):
5255 client_time = fmt_dt(self.earlier)
56+ conf["raise_exception"] = True
5357 response = self.client.put(
5458 "/",
5559 {"lastUpdated": client_time},
5660 format="json",
5761 )
5862 self.assertEqual(response.status_code, conf["noupdate_code"])
63+ conf["raise_exception"] = False
64+ response = self.client.put(
65+ "/",
66+ {"lastUpdated": client_time},
67+ format="json",
68+ )
69+ self.assertEqual(response.status_code, 200)
5970
6071 def test_put_client_is_equal(self):
6172 client_time = fmt_dt(self.now)
73+ conf["raise_exception"] = True
6274 response = self.client.put(
6375 "/",
6476 {"lastUpdated": client_time},