def test_not_renew_cert(self, mock_utils, mock_logging, mock_cert_client, paho_mqtt_mock, json_mock): "Sould not renew cert" client = MQTTClient("123", "987", False, False) client.should_renew_now = MagicMock() client.should_renew_now.return_value = True mock_cert_client.new_cert().renew_cert.return_value = Exception('exception') with self.assertRaises(Exception): client.renew_cert() mock_utils.fire_locust_failure.assert_called_once() client.should_renew_now.return_value = False client.renew_cert() mock_utils.reset_mock() mock_logging.reset_mock() mock_cert_client.reset_mock() paho_mqtt_mock.reset_mock() json_mock.reset_mock()
def test_not_renew_cert(self, _mock_paho, _mock_cert_utils): "Should not renew cert" client = MQTTClient("123", "987", False, False) client.should_renew_now = MagicMock() client.should_renew_now.return_value = False client.renew_cert_and_emit_event = MagicMock() client.renew_cert() self.assertFalse(client.should_renew) client.should_renew_now.assert_called() self.assertTrue(client.renew_cert_and_emit_event.call_count == 0)
def test_renew_cert(self, mock_utils, mock_logging, mock_cert_client, paho_mqtt_mock, json_mock): "Sould renew cert" client = MQTTClient("123", "987", False, True) client.should_renew_now = MagicMock() client.should_renew_now.return_value = True mock_cert_client.new_cert().renew_cert.return_value = True client.setup() client.renew_cert() client.new_cert.renew_cert.assert_called_once() mock_utils.fire_locust_success.assert_called_once() self.assertFalse(client.should_renew) mock_utils.reset_mock() mock_logging.reset_mock() mock_cert_client.reset_mock() paho_mqtt_mock.reset_mock() json_mock.reset_mock()