Changeset 1931 for trunk/server/common/oursrc/scripts-static-cat/test.py
- Timestamp:
- Jul 16, 2011, 8:10:46 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/scripts-static-cat/test.py
r1900 r1931 1 #!/usr/bin/python2 3 from subprocess import Popen, PIPE4 5 6 # Make test.html in this directory available at this url:7 URL = "http://cberzan.scripts.mit.edu/static-cat.cgi/test.html"8 9 10 def test_all():11 truth =\12 r"""HTTP/1.1 200 OK13 Date: Sun, 12 Jun 2011 02:59:36 GMT14 Server: Apache15 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT16 ETag: "823818c-2c6-4a576be3968c0"17 Accept-Ranges: bytes18 Content-Length: 71019 Vary: Accept-Encoding20 Content-Type: text/html21 22 Sunt autem quidam e nostris, qui haec subtilius velint tradere et negent satis esse, quid bonum sit aut quid malum, sensu iudicari, sed animo etiam ac ratione intellegi posse et voluptatem ipsam per se esse expetendam et dolorem ipsum per se esse fugiendum. itaque aiunt hanc quasi naturalem atque insitam in animis nostris inesse notionem, ut alterum esse appetendum, alterum aspernandum sentiamus. Alii autem, quibus ego assentior, cum a philosophis compluribus permulta dicantur, cur nec voluptas in bonis sit numeranda nec in malis dolor, non existimant oportere nimium nos causae confidere, sed et argumentandum et accurate disserendum et rationibus conquisitis de voluptate et dolore disputandum putant."""23 p = Popen(["curl", URL, "-s", "-D", "-"], stdout=PIPE)24 result = p.communicate()[0]25 print "TODO finish test..."26 # LEFT TODO: use mimeheaders or something (http://stackoverflow.com/questions/4685217/parse-raw-http-headers)27 # to parse headers and make sure they're OK; compare content and make sure it matches byte-for-byte.28 29 30 def test_one_range():31 truth =\32 r"""HTTP/1.1 206 Partial Content33 Date: Sun, 12 Jun 2011 03:05:41 GMT34 Server: Apache35 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT36 ETag: "823818c-2c6-4a576be3968c0"37 Accept-Ranges: bytes38 Content-Length: 10139 Vary: Accept-Encoding40 Content-Range: bytes 100-200/71041 Content-Type: text/html42 43 aut quid malum, sensu iudicari, sed animo etiam ac ratione intellegi posse et voluptatem ipsam per se"""44 p = Popen(["curl", "-r", "100-200", URL, "-s", "-D", "-"], stdout=PIPE)45 result = p.communicate()[0]46 print "TODO finish test..."47 # LEFT TODO: see above48 49 50 def test_overlapping_ranges():51 truth =\52 r"""HTTP/1.1 206 Partial Content53 Date: Sun, 12 Jun 2011 03:07:02 GMT54 Server: Apache55 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT56 ETag: "823818c-2c6-4a576be3968c0"57 Accept-Ranges: bytes58 Content-Length: 39559 Vary: Accept-Encoding60 Content-Type: multipart/byteranges; boundary=4a57b18cf808c49ff61 62 63 --4a57b18cf808c49ff64 Content-type: text/html65 Content-range: bytes 100-200/71066 67 aut quid malum, sensu iudicari, sed animo etiam ac ratione intellegi posse et voluptatem ipsam per se68 --4a57b18cf808c49ff69 Content-type: text/html70 Content-range: bytes 150-250/71071 72 ratione intellegi posse et voluptatem ipsam per se esse expetendam et dolorem ipsum per se esse fugi73 --4a57b18cf808c49ff--74 """75 p = Popen(["curl", "-r", "100-200,150-250", URL, "-s", "-D", "-"], stdout=PIPE)76 result = p.communicate()[0]77 print "TODO finish test..."78 # LEFT TODO: see above, with the additional complication that the separating string varies.79 80 81 def test_nonoverlapping_ranges():82 truth =\83 r"""HTTP/1.1 206 Partial Content84 Date: Sun, 12 Jun 2011 03:08:19 GMT85 Server: Apache86 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT87 ETag: "823818c-2c6-4a576be3968c0"88 Accept-Ranges: bytes89 Content-Length: 42990 Vary: Accept-Encoding91 Content-Type: multipart/byteranges; boundary=4a57b1d5f1d8949fd92 93 94 --4a57b1d5f1d8949fd95 Content-type: text/html96 Content-range: bytes 50-100/71097 98 lint tradere et negent satis esse, quid bonum sit a99 --4a57b1d5f1d8949fd100 Content-type: text/html101 Content-range: bytes 150-200/710102 103 ratione intellegi posse et voluptatem ipsam per se104 --4a57b1d5f1d8949fd105 Content-type: text/html106 Content-range: bytes 250-300/710107 108 iendum. itaque aiunt hanc quasi naturalem atque ins109 --4a57b1d5f1d8949fd--110 """111 p = Popen(["curl", "-r", "50-100,150-200,250-300", URL, "-s", "-D", "-"], stdout=PIPE)112 result = p.communicate()[0]113 print "TODO finish test..."114 # LEFT TODO: see above, with the additional complication that the separating string varies.115 116 117 if __name__ == "__main__":118 print "Unfinished tests! Read the source."119 test_all()120 test_one_range()121 test_overlapping_ranges()122 test_nonoverlapping_ranges()123 print "Test passed."
Note: See TracChangeset
for help on using the changeset viewer.