コード例 #1
0
 def test_negative_skew(self):
     now = datetime.datetime.utcnow() + datetime.timedelta(minutes=-11)
     now_str = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
     response = MagicMock()
     response.headers = {'Date': now_str}
     with self.assertRaises(ClockSkew):
         ClockSkewHook().post_request('POST', 'http://example.com', {}, response)
コード例 #2
0
 def test_no_skew(self):
     now = datetime.datetime.utcnow()
     now_str = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
     response = MagicMock()
     response.headers = {'Date': now_str}
     ClockSkewHook().post_request('POST', 'http://example.com', {},
                                  response)
コード例 #3
0
 def test_bad_month(self):
     response = MagicMock()
     response.headers = {'Date': 'Fri, 16 XXX 2016 20:52:30 GMT'}
     with self.assertRaises(BadDateFormat):
         ClockSkewHook().post_request('POST', 'http://example.com', {}, response)
コード例 #4
0
 def test_bad_format(self):
     response = MagicMock()
     response.headers = {'Date': 'bad format'}
     with self.assertRaises(BadDateFormat):
         ClockSkewHook().post_request('POST', 'http://example.com', {}, response)