from atlas_um.analytics.processors import AsyncAmplitudeProcessor from atlas_um.consts import SystemEvents class TestAsyncAmplitudeProcessor: def test_process(self, mocker, faker): test_user_id = faker.pystr() test_event = SystemEvents.successful_token_refresh test_context = {"cont_arg1": "cont_value1"} test_kwargs = {"arg1": "value1", "user_id": test_user_id} mocked_send_to_amplitude = mocker.patch.object( AsyncAmplitudeProcessor, "send_to_amplitude" ) processor = AsyncAmplitudeProcessor() processor.process(test_event, test_context, **test_kwargs) assert mocked_send_to_amplitude.delay.call_args_list == [ mocker.call( { "event_type": "Successful token refresh", "user_id": test_user_id, "event_properties": { "arg1": "value1", "cont_arg1": "cont_value1", "user_id": test_user_id, }, } ) ] def test_send_to_amplitude(self, mocker, faker): mocked_amplitude = mocker.patch("atlas_um.extensions.amplitude") data = faker.pydict() AsyncAmplitudeProcessor.send_to_amplitude(data) assert mocked_amplitude.send_event.call_args_list == [ mocker.call(data) ]