Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/twisted_8_1/twisted/web/test/test_static.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 from twisted.trial import unittest
2 import os
3 from twisted.web import static
4
5 class FakeRequest:
6 method = 'GET'
7
8 _headers = None
9 _setHeaders = None
10 _written = ''
11
12 def __init__(self):
13 self._headers = {}
14 self._setHeaders = {}
15
16 def getHeader(self, k):
17 if self._headers is None:
18 return None
19 return self._headers.get(k)
20
21 def setHeader(self, k, v):
22 self._setHeaders.setdefault(k, []).append(v)
23
24 def setLastModified(self, x):
25 pass
26 def registerProducer(self, producer, x):
27 producer.resumeProducing()
28 def unregisterProducer(self):
29 pass
30 def finish(self):
31 pass
32
33 def write(self, data):
34 self._written = self._written + data
35
36 class Range(unittest.TestCase):
37 todo = (unittest.FailTest, 'No range support yet.')
38
39 def setUp(self):
40 self.tmpdir = self.mktemp()
41 os.mkdir(self.tmpdir)
42 name = os.path.join(self.tmpdir, 'junk')
43 f = file(name, 'w')
44 f.write(8000 * 'x')
45 f.close()
46 self.file = static.File(name)
47 self.request = FakeRequest()
48
49 def testBodyLength(self):
50 self.request._headers['range'] = 'bytes=0-1999'
51 self.file.render(self.request)
52 self.assertEquals(len(self.request._written), 2000)
53
54 def testContentLength(self):
55 """Content-Length of a request is correct."""
56 self.request._headers['range'] = 'bytes=0-1999'
57 self.file.render(self.request)
58 self.assertEquals(self.request._setHeaders['content-length'], ['2000'])
59
60 def testContentRange(self):
61 """Content-Range of a request is correct."""
62 self.request._headers['range'] = 'bytes=0-1999'
63 self.file.render(self.request)
64 self.assertEquals(self.request._setHeaders.get('content-range'), ['bytes 0-1999/8000'])
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/web/test/test_soap.py ('k') | third_party/twisted_8_1/twisted/web/test/test_tap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698