Joe Gregorio | d27ae3e | 2010-12-09 15:01:27 -0500 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
| 2 | # |
| 3 | # Copyright 2010 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """One-line documentation for util module. |
| 6 | |
| 7 | A detailed description of util. |
| 8 | """ |
| 9 | |
| 10 | __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
| 11 | |
| 12 | import httplib2 |
| 13 | import os |
| 14 | |
| 15 | DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') |
| 16 | |
| 17 | |
| 18 | class HttpMock(object): |
| 19 | |
| 20 | def __init__(self, filename, headers): |
| 21 | f = file(os.path.join(DATA_DIR, filename), 'r') |
| 22 | self.data = f.read() |
| 23 | f.close() |
| 24 | self.headers = headers |
| 25 | |
| 26 | def request(self, uri, method="GET", body=None, headers=None, redirections=1, connection_type=None): |
| 27 | return httplib2.Response(self.headers), self.data |