Beispiel #1
0
 def test_post(self):
     with open('httputil.py', 'rb') as fi:
         data = fi.read()
     with httputil.download(self.target + '/post/postmatch',
                            data=data).makefile() as f:
         body = f.read()
     self.assertEqual(body, str(len(data)).encode(httputil.ENCODING))
Beispiel #2
0
 def test_post_file(self):
     with open('httputil.py', 'rb') as fi:
         with httputil.download(self.target + '/post/postmatch',
                                data=fi).makefile() as f:
             body = f.read()
     with open('httputil.py', 'rb') as fi:
         data = fi.read()
     self.assertEqual(body, str(len(data)).encode(httputil.ENCODING))
Beispiel #3
0
 def test_getfile(self):
     with httputil.download(self.target + '/urlmatch').makefile() as f:
         body = f.read()
     self.assertEqual(
         json.loads(body.decode('utf-8')),
         {
             'page': 'main',
             'path': 'urlmatch',
             'count': 0,
             'match': {},
             'param': {'main param': 1}
         })
Beispiel #4
0
 def test_getfile(self):
     with httputil.download(self.target + '/urlmatch').makefile() as f:
         body = f.read()
     self.assertEqual(
         json.loads(body.decode('utf-8')), {
             'page': 'main',
             'path': 'urlmatch',
             'count': 0,
             'match': {},
             'param': {
                 'main param': 1
             }
         })
Beispiel #5
0
def download(url):
    with closing(httputil.download(url)) as resp:
        return resp.readbody()
Beispiel #6
0
def download(url):
    with closing(httputil.download(url)) as resp:
        return resp.readbody()