Ignore:
Timestamp:
Jul 16, 2011, 8:10:46 PM (13 years ago)
Author:
geofft
Message:
Revert r1900

This commit isn't usable as-is. We will probably be applying / working
on parts of it after our Fedora 15 release.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/scripts-static-cat/test.py

    r1900 r1931  
    1 #!/usr/bin/python
    2 
    3 from subprocess import Popen, PIPE
    4 
    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 OK
    13 Date: Sun, 12 Jun 2011 02:59:36 GMT
    14 Server: Apache
    15 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT
    16 ETag: "823818c-2c6-4a576be3968c0"
    17 Accept-Ranges: bytes
    18 Content-Length: 710
    19 Vary: Accept-Encoding
    20 Content-Type: text/html
    21 
    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 Content
    33 Date: Sun, 12 Jun 2011 03:05:41 GMT
    34 Server: Apache
    35 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT
    36 ETag: "823818c-2c6-4a576be3968c0"
    37 Accept-Ranges: bytes
    38 Content-Length: 101
    39 Vary: Accept-Encoding
    40 Content-Range: bytes 100-200/710
    41 Content-Type: text/html
    42 
    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 above
    48 
    49 
    50 def test_overlapping_ranges():
    51     truth =\
    52 r"""HTTP/1.1 206 Partial Content
    53 Date: Sun, 12 Jun 2011 03:07:02 GMT
    54 Server: Apache
    55 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT
    56 ETag: "823818c-2c6-4a576be3968c0"
    57 Accept-Ranges: bytes
    58 Content-Length: 395
    59 Vary: Accept-Encoding
    60 Content-Type: multipart/byteranges; boundary=4a57b18cf808c49ff
    61 
    62 
    63 --4a57b18cf808c49ff
    64 Content-type: text/html
    65 Content-range: bytes 100-200/710
    66 
    67 aut quid malum, sensu iudicari, sed animo etiam ac ratione intellegi posse et voluptatem ipsam per se
    68 --4a57b18cf808c49ff
    69 Content-type: text/html
    70 Content-range: bytes 150-250/710
    71 
    72  ratione intellegi posse et voluptatem ipsam per se esse expetendam et dolorem ipsum per se esse fugi
    73  --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 Content
    84 Date: Sun, 12 Jun 2011 03:08:19 GMT
    85 Server: Apache
    86 Last-Modified: Sat, 11 Jun 2011 21:55:23 GMT
    87 ETag: "823818c-2c6-4a576be3968c0"
    88 Accept-Ranges: bytes
    89 Content-Length: 429
    90 Vary: Accept-Encoding
    91 Content-Type: multipart/byteranges; boundary=4a57b1d5f1d8949fd
    92 
    93 
    94 --4a57b1d5f1d8949fd
    95 Content-type: text/html
    96 Content-range: bytes 50-100/710
    97 
    98 lint tradere et negent satis esse, quid bonum sit a
    99 --4a57b1d5f1d8949fd
    100 Content-type: text/html
    101 Content-range: bytes 150-200/710
    102 
    103  ratione intellegi posse et voluptatem ipsam per se
    104  --4a57b1d5f1d8949fd
    105  Content-type: text/html
    106  Content-range: bytes 250-300/710
    107 
    108  iendum. itaque aiunt hanc quasi naturalem atque ins
    109  --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.