Failing test for If-Modified-Since
authorEmil Mikulic <emikulic@gmail.com>
Sun, 1 May 2011 08:20:26 +0000 (18:20 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Sun, 28 Apr 2013 10:56:46 +0000 (20:56 +1000)
devel/test.py

index 169f225..218b60a 100755 (executable)
@@ -178,6 +178,19 @@ class TestFileGet(TestHelper):
         self.assertEquals(hdrs["Content-Length"], str(self.datalen))
         self.assertEquals(hdrs["Content-Type"], "image/jpeg")
 
+    def test_if_modified_since(self):
+        resp1 = Conn().get(self.url, method="HEAD")
+        status, hdrs, body = parse(resp1)
+        lastmod = hdrs["Last-Modified"]
+
+        resp2 = Conn().get(self.url, method="GET", req_hdrs =
+            {"If-Modified-Since": lastmod })
+        status, hdrs, body = parse(resp2)
+        self.assertContains(status, "304 Not Modified")
+        self.assertFalse(hdrs.has_key("Last-Modified"))
+        self.assertFalse(hdrs.has_key("Content-Length"))
+        self.assertFalse(hdrs.has_key("Content-Type"))
+
 if __name__ == '__main__':
     setUpModule()
     unittest.main()