def test_event_to_transformer(self, config, mock_transformer, mock_session, mock_auth): event = UsageEvent("status", "name", "namespace", "deployment_id", "repository") reporter = UsageReporter(config, mock_transformer, mock_session, mock_auth) reporter._event_queue = [event] reporter() mock_transformer.assert_called_once_with(event.status, event.app_name, event.namespace, event.deployment_id, event.repository)
def test_post_to_webhook(self, config, mock_transformer, mock_session, mock_auth): event = UsageEvent("status", "name", "namespace", "deployment_id", "repository") reporter = UsageReporter(config, mock_transformer, mock_session, mock_auth) reporter._event_queue = [event] payload = {"dummy": "payload"} mock_transformer.return_value = payload reporter() mock_session.post.assert_called_once_with(config.usage_reporting_endpoint, json=payload, auth=mock_auth)