@@ -163,6 +163,28 @@ def test_announce_fails_with_non_json(self, mock_requests_session_put):
163163 self .assertEqual (len (log .records ), 1 )
164164 self .assertIn ('response is not JSON' , log .output [0 ])
165165
166+ @patch .object (requests .Session , "put" )
167+ def test_announce_fails_with_empty_list_json (self , mock_requests_session_put ):
168+ test_pid = 4242
169+ test_process_name = 'test_process'
170+ test_process_args = ['-v' , '-d' ]
171+ test_agent_uuid = '83bf1e09-ab16-4203-abf5-34ee0977023a'
172+
173+ mock_response = MagicMock ()
174+ mock_response .status_code = 200
175+ mock_response .content = '[]'
176+ mock_requests_session_put .return_value = mock_response
177+
178+ self .create_agent_and_setup_tracer ()
179+ d = Discovery (pid = test_pid ,
180+ name = test_process_name , args = test_process_args )
181+ with self .assertLogs (logger , level = 'DEBUG' ) as log :
182+ payload = self .agent .announce (d )
183+ self .assertIsNone (payload )
184+ self .assertEqual (len (log .output ), 1 )
185+ self .assertEqual (len (log .records ), 1 )
186+ self .assertIn ('payload has no fields' , log .output [0 ])
187+
166188
167189 @patch .object (requests .Session , "put" )
168190 def test_announce_fails_with_missing_pid (self , mock_requests_session_put ):
0 commit comments