Ejemplo n.º 1
0
 def test_http_fail_full(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 404
     mock_get.return_value = mock_response
     http_smoke_test.check_urls('pro1', full=True)
     self.assertEqual(mock_get.call_count,
                      len(http_smoke_test.SHORT_RUN +
                          http_smoke_test.FULL_RUN))
Ejemplo n.º 2
0
 def test_http_success_full(self, mock_list, mock_get):
     mock_list.return_value = FALLBACK_URLS
     mock_response = mock.Mock()
     mock_response.status_code = 200
     mock_get.return_value = mock_response
     self.assertTrue(check_urls('pro1'))
     self.assertEqual(mock_get.call_count, len(FALLBACK_URLS))
Ejemplo n.º 3
0
 def test_http_fail_url_list(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 404
     mock_get.return_value = mock_response
     mock_response.json.return_value = []
     result = check_urls('pro1', url_list='/')
     self.assertFalse(result)
     self.assertEqual(mock_get.call_count, 1)
Ejemplo n.º 4
0
 def test_http_fail_full(self, mock_list, mock_get):
     mock_response = mock.Mock()
     mock_list.return_value = FALLBACK_URLS
     mock_response.status_code = 404
     mock_get.return_value = mock_response
     result = check_urls('pro1')
     self.assertFalse(result)
     self.assertEqual(mock_get.call_count, len(FALLBACK_URLS))
Ejemplo n.º 5
0
 def test_allowed_timeouts(self, mock_get):
     allowed = http_smoke_test.ALLOWED_TIMEOUTS
     mock_ok_response = mock.Mock()
     mock_ok_response.status_code = 200
     short_run_remainder = len(http_smoke_test.SHORT_RUN) - allowed
     allowed_list = [requests.exceptions.Timeout] * allowed
     ok_list = [mock_ok_response] * short_run_remainder
     side_effect_list = allowed_list + ok_list
     mock_get.side_effect = side_effect_list
     self.assertTrue(http_smoke_test.check_urls('pro1'))
Ejemplo n.º 6
0
 def test_allowed_timeouts(self, mock_get):
     allowed = http_smoke_test.ALLOWED_TIMEOUTS
     mock_ok_response = mock.Mock()
     mock_ok_response.status_code = 200
     short_run_remainder = len(http_smoke_test.SHORT_RUN) - allowed
     allowed_list = [requests.exceptions.Timeout] * allowed
     ok_list = [mock_ok_response] * short_run_remainder
     side_effect_list = allowed_list + ok_list
     mock_get.side_effect = side_effect_list
     self.assertTrue(http_smoke_test.check_urls('pro1'))
Ejemplo n.º 7
0
 def test_http_fail_timeout_full(self, mock_get):
     mock_get.side_effect = requests.exceptions.Timeout
     http_smoke_test.check_urls('pro1', full=True)
     self.assertEqual(mock_get.call_count, len(http_smoke_test.FULL_RUN))
Ejemplo n.º 8
0
 def test_http_fail_request_error(self, mock_get):
     mock_get.side_effect = requests.exceptions.RequestException
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 9
0
 def test_http_fail_full(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 404
     mock_get.return_value = mock_response
     http_smoke_test.check_urls('pro1', full=True)
     self.assertEqual(mock_get.call_count, len(http_smoke_test.FULL_RUN))
Ejemplo n.º 10
0
 def test_http_fail_timeout_short(self, mock_get):
     mock_get.side_effect = requests.exceptions.Timeout
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 11
0
 def test_http_fail_request_error(self, mock_get):
     mock_get.side_effect = requests.exceptions.RequestException
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 12
0
 def test_http_fail_short(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 404
     mock_get.return_value = mock_response
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 13
0
 def test_http_fail_timeout_short(self, mock_get):
     mock_get.side_effect = requests.exceptions.Timeout
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 14
0
 def test_http_fail_timeout_full(self, mock_get):
     mock_get.side_effect = requests.exceptions.Timeout
     http_smoke_test.check_urls('pro1', full=True)
     self.assertEqual(mock_get.call_count, len(http_smoke_test.FULL_RUN))
Ejemplo n.º 15
0
 def test_http_fail_timeout(self, mock_get):
     check_urls('pro1', url_list=['/'])
     self.assertEqual(mock_get.call_count, 1)
Ejemplo n.º 16
0
 def test_http_success_short(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 200
     mock_get.return_value = mock_response
     http_smoke_test.check_urls('pro1')
     self.assertEqual(mock_get.call_count, len(http_smoke_test.SHORT_RUN))
Ejemplo n.º 17
0
 def test_http_fail_timeout_full(self, mock_get):
     expected_call_count = len(FALLBACK_URLS) + 1  # one call for s3
     self.assertFalse(check_urls('pro1'))
     self.assertEqual(mock_get.call_count, expected_call_count)
Ejemplo n.º 18
0
 def test_http_success_url_list(self, mock_get):
     mock_response = mock.Mock()
     mock_response.status_code = 200
     mock_get.return_value = mock_response
     self.assertTrue(check_urls('pro1', url_list=['/', '/ask-cfpb/']))
     self.assertEqual(mock_get.call_count, 2)
Ejemplo n.º 19
0
 def test_http_fail_request_error(self, mock_get):
     result = check_urls('www', url_list=['/', '/ask-cfpb'])
     self.assertFalse(result)
Ejemplo n.º 20
0
 def test_http_fail_connection_error(self, mock_get):
     check_urls('pro1')
     self.assertEqual(
         mock_get.call_count,
         len(FALLBACK_URLS) + 1  # one call for s3
     )
Ejemplo n.º 21
0
 def test_allowed_timeouts(self, mock_get):
     too_many = ALLOWED_TIMEOUTS + 2
     urls = FALLBACK_URLS[:too_many]
     self.assertFalse(check_urls('pro1', url_list=urls))