Пример #1
0
 def test_get_stats_yaml(self, mock_requests):
     mock_response = mock.Mock()
     mock_response.text = MOCK_YAML
     mock_response.ok = True
     mock_requests.return_value = mock_response
     data = nat_stats.get_stats_yaml()
     self.assertTrue(mock_requests.call_count == 1)
     self.assertTrue(data['completion_rate']['max'] == 1)
     mock_response.ok = False
     mock_requests.return_value = mock_response
     data = nat_stats.get_stats_yaml()
     self.assertTrue(mock_requests.call_count == 2)
     self.assertTrue(data == {})
Пример #2
0
 def test_get_stats_yaml(self, mock_requests):
     mock_response = mock.Mock()
     mock_response.text = MOCK_YAML
     mock_response.ok = True
     mock_requests.return_value = mock_response
     data = nat_stats.get_stats_yaml()
     self.assertTrue(mock_requests.call_count == 1)
     self.assertTrue(data['completion_rate']['max'] == 1)
     mock_response.ok = False
     mock_requests.return_value = mock_response
     data = nat_stats.get_stats_yaml()
     self.assertTrue(mock_requests.call_count == 2)
     self.assertTrue(data == {})
Пример #3
0
 def test_nat_stats_request_returns_none(self, mock_requests, mock_yaml):
     mock_yaml.side_effect = AttributeError
     self.assertEqual(nat_stats.get_stats_yaml(), {})
Пример #4
0
 def test_bad_nat_stats_request(self, mock_requests):
     mock_requests.side_effect = requests.exceptions.ConnectionError
     self.assertEqual(nat_stats.get_stats_yaml(), {})