@@ -47,29 +47,48 @@ async def test_kafka_message_processing(self):
4747 # Mock statsd
4848 service ._statsd = Mock ()
4949
50- # Test artifact analysis message with iOS artifact
51- ios_payload : PreprodArtifactEvents = {
52- "artifact_id " : "ios-test-123 " ,
53- "project_id " : "test-project-ios" ,
54- "organization_id " : "test-org-123 " ,
50+ # Mock service config to make the service appear initialized
51+ service . _service_config = {
52+ "statsd_host " : "127.0.0.1 " ,
53+ "statsd_port " : 8125 ,
54+ "sentry_base_url " : "https://sentry.example.com " ,
5555 }
5656
57- # handle_kafka_message is synchronous
58- service .handle_kafka_message (ios_payload )
57+ # Mock process_artifact_analysis to avoid actual processing
58+ with patch .object (service , "process_artifact_analysis" ) as mock_process :
59+ # Test artifact analysis message with iOS artifact
60+ ios_payload : PreprodArtifactEvents = {
61+ "artifact_id" : "ios-test-123" ,
62+ "project_id" : "test-project-ios" ,
63+ "organization_id" : "test-org-123" ,
64+ }
5965
60- # Verify statsd metrics were sent
61- service ._statsd .increment .assert_any_call ("launchpad.artifact.processing.started" )
62- service ._statsd .increment .assert_any_call ("launchpad.artifact.processing.completed" )
66+ # handle_kafka_message is synchronous
67+ service .handle_kafka_message (ios_payload )
6368
64- # Test artifact analysis message with Android artifact
65- android_payload : PreprodArtifactEvents = {
66- "artifact_id" : "android-test-456" ,
67- "project_id" : "test-project-android" ,
68- "organization_id" : "test-org-456" ,
69- }
69+ # Verify the processing method was called
70+ mock_process .assert_called_once_with ("ios-test-123" , "test-project-ios" , "test-org-123" )
71+
72+ # Verify statsd metrics were sent
73+ service ._statsd .increment .assert_any_call ("launchpad.artifact.processing.started" )
74+ service ._statsd .increment .assert_any_call ("launchpad.artifact.processing.completed" )
75+
76+ # Reset mocks for next test
77+ mock_process .reset_mock ()
78+ service ._statsd .reset_mock ()
79+
80+ # Test artifact analysis message with Android artifact
81+ android_payload : PreprodArtifactEvents = {
82+ "artifact_id" : "android-test-456" ,
83+ "project_id" : "test-project-android" ,
84+ "organization_id" : "test-org-456" ,
85+ }
86+
87+ # handle_kafka_message is synchronous
88+ service .handle_kafka_message (android_payload )
7089
71- # handle_kafka_message is synchronous
72- service . handle_kafka_message ( android_payload )
90+ # Verify the processing method was called
91+ mock_process . assert_called_once_with ( "android-test-456" , "test-project-android" , "test-org-456" )
7392
7493 @pytest .mark .asyncio
7594 async def test_error_handling_in_message_processing (self ):
0 commit comments