コード例 #1
0
ファイル: test_http.py プロジェクト: gscom052/webchk
 def test_redirect_follows(self):
     url = 'https://httpstat.us/307'
     resp = http_response(url, TIMEOUT)
     total = 0
     while resp.redirect:
         fmt = '{} ... {} {} ({})'.format(resp.url, resp.status, resp.desc,
                                          resp.latency)
         self.assertEqual(str(resp), fmt)
         total += 1
         resp = resp.redirect
     self.assertEqual(total, 1)
コード例 #2
0
ファイル: test_http.py プロジェクト: sickcrow/webchk
 def test_absolute_redirect_follows(self):
     url = 'http://httpbin.org/absolute-redirect/{}'
     resp = http_response(url.format(3))
     count = 3
     total = 0
     while resp.redirect:
         fmt = '{} ... {} {} ({})'.format(resp.url, resp.status, resp.desc,
                                          resp.latency)
         self.assertEqual(str(resp), fmt)
         count -= 1
         total += 1
         resp = resp.redirect
     self.assertEqual(total, 3)
コード例 #3
0
ファイル: test_http.py プロジェクト: gscom052/webchk
 def test_unresolvable_domains(self):
     resp = http_response('http://!.c', TIMEOUT)
     self.assertEqual(str(resp), 'http://!.c ... Could not resolve')
コード例 #4
0
ファイル: test_http.py プロジェクト: gscom052/webchk
 def test_http_response(self):
     for url, result in self.urls.items():
         resp_code = http_response(url, TIMEOUT).status
         self.assertEqual(resp_code, result[0], url)