Exemple #1
0
 def test_transmission_307_circular_reference(self):
     mixin = TransportMixin()
     mixin.options = Options()
     mixin._consecutive_redirects = 0
     mixin.options.endpoint = "https://example.com"
     with mock.patch('requests.post') as post:
         post.return_value = MockResponse(
             307, '{}', {"location": "https://example.com"})  # noqa: E501
         result = mixin._transmit([1, 2, 3])
         self.assertEqual(result, -307)
     self.assertEqual(post.call_count, _MAX_CONSECUTIVE_REDIRECTS)
     self.assertEqual(mixin.options.endpoint, "https://example.com")
Exemple #2
0
 def test_transmission_307(self):
     mixin = TransportMixin()
     mixin.options = Options()
     mixin._consecutive_redirects = 0
     mixin.options.endpoint = "test.endpoint"
     with LocalFileStorage(os.path.join(TEST_FOLDER, self.id())) as stor:
         mixin.storage = stor
         mixin.storage.put([1, 2, 3])
         with mock.patch('requests.post') as post:
             post.return_value = MockResponse(
                 307, '{}',
                 {"location": "https://example.com"})  # noqa: E501
             mixin._transmit_from_storage()
         self.assertEqual(post.call_count, _MAX_CONSECUTIVE_REDIRECTS)
         self.assertEqual(len(os.listdir(mixin.storage.path)), 0)
         self.assertEqual(mixin.options.endpoint, "https://example.com")
Exemple #3
0
 def test_statsbeat_307(self):
     _requests_map.clear()
     mixin = TransportMixin()
     mixin.options = Options()
     mixin._consecutive_redirects = 0
     mixin.options.endpoint = "test.endpoint"
     with mock.patch('requests.post') as post:
         post.return_value = MockResponse(
             307, '{}', {"location": "https://example.com"})  # noqa: E501
         result = mixin._transmit([1, 2, 3])
         self.assertEqual(len(_requests_map), 4)
         self.assertIsNotNone(_requests_map['duration'])
         self.assertEqual(_requests_map['exception'], 1)
         self.assertEqual(_requests_map['count'], 10)
         self.assertEqual(_requests_map['failure'], 10)
         self.assertEqual(result, -307)
     _requests_map.clear()