mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Implement straightforward GET test.
This commit is contained in:
@ -4,6 +4,7 @@ import socket
|
|||||||
import signal
|
import signal
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
WWWROOT = "tmp.httpd.tests"
|
WWWROOT = "tmp.httpd.tests"
|
||||||
|
|
||||||
@ -150,6 +151,26 @@ def setUpModule():
|
|||||||
]:
|
]:
|
||||||
makeSimpleCases(*args)
|
makeSimpleCases(*args)
|
||||||
|
|
||||||
|
class TestFileGet(TestHelper):
|
||||||
|
def setUp(self):
|
||||||
|
self.datalen = 2345
|
||||||
|
self.data = "".join(
|
||||||
|
[chr(random.randint(0,255)) for _ in xrange(self.datalen)])
|
||||||
|
self.url = "/data.jpeg"
|
||||||
|
self.fn = WWWROOT + self.url
|
||||||
|
open(self.fn, "w").write(self.data)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
os.unlink(self.fn)
|
||||||
|
|
||||||
|
def test_file_get(self):
|
||||||
|
resp = Conn().get(self.url)
|
||||||
|
status, hdrs, body = parse(resp)
|
||||||
|
self.assertContains(status, "200 OK")
|
||||||
|
self.assertEquals(hdrs["Content-Length"], str(self.datalen))
|
||||||
|
self.assertEquals(hdrs["Content-Type"], "image/jpeg")
|
||||||
|
self.assertEquals(body, self.data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setUpModule()
|
setUpModule()
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user