@@ -324,6 +324,48 @@ def test_transform_business_service(business_service):
324324 )
325325
326326
327+ @pytest .mark .parametrize (
328+ "input_name,expected_name" ,
329+ [
330+ # Basic cases
331+ ("Simple Service" , "simple-service" ),
332+ ("Test_Service" , "test-service" ),
333+ ("Service.Name" , "service.name" ),
334+ # Edge cases that would cause issues with old logic
335+ (" Leading spaces" , "leading-spaces" ),
336+ ("Trailing spaces " , "trailing-spaces" ),
337+ (" Both sides " , "both-sides" ),
338+ ("Multiple spaces" , "multiple-spaces" ),
339+ # Special characters
340+ ("Service@Name" , "service-name" ),
341+ ("Service!@#$%Name" , "service-name" ),
342+ ("Service(with)parens" , "service-with-parens" ),
343+ # Mixed cases
344+ (" Service@Name " , "service-name" ),
345+ ("##Service Name##" , "service-name" ),
346+ ("!!!Service!!!Name!!!" , "service-name" ),
347+ ],
348+ )
349+ def test_service_name_normalization (input_name , expected_name ):
350+ """Test service name normalization handles various edge cases correctly."""
351+ # Create a mock technical service
352+ service = Mock (spec = TechnicalService )
353+ service .name = input_name
354+ service .description = "Test description"
355+ service .id = "P123456"
356+ service .status = "active"
357+ service .html_url = "https://pagerduty.com/services/P123456"
358+ service .self_url = "https://api.pagerduty.com/services/P123456"
359+
360+ # Transform the service
361+ component = _transform_service (service )
362+
363+ # Check that the name was normalized correctly
364+ assert (
365+ component ["metadata" ]["name" ] == expected_name
366+ ), f"Expected '{ expected_name } ' for input '{ input_name } ', got '{ component ['metadata' ]['name' ]} '"
367+
368+
327369def test_validate_component ():
328370 """Test component validation."""
329371 # Test valid component
0 commit comments