@@ -836,7 +836,7 @@ def test_device_registration_update_hw_info_no_config(self):
836836 self .assertEqual (d .system , params ["system" ])
837837 self .assertEqual (d .model , params ["model" ])
838838
839- @patch .object (Device , ' skip_push_update_on_save' )
839+ @patch .object (Device , " skip_push_update_on_save" )
840840 def test_device_registration_update_hostname (self , mocked_method ):
841841 """
842842 Test that hostname is updated when the name in payload
@@ -860,7 +860,10 @@ def test_device_registration_update_hostname(self, mocked_method):
860860 self .assertEqual (device .name , "new-custom-hostname" )
861861 mocked_method .assert_called_once ()
862862
863- def test_device_registration_hostname_not_updated_when_mac_address (self ):
863+ @patch .object (Device , "skip_push_update_on_save" )
864+ def test_device_registration_hostname_not_updated_when_mac_address (
865+ self , mocked_method
866+ ):
864867 """
865868 Test that hostname is not updated when the name in payload
866869 equals the MAC address (agents send MAC address as hostname
@@ -880,17 +883,22 @@ def test_device_registration_hostname_not_updated_when_mac_address(self):
880883 self .assertEqual (response .status_code , 201 )
881884 device .refresh_from_db ()
882885 self .assertEqual (device .name , "meaningful-hostname" )
886+ mocked_method .assert_not_called ()
883887
884- def test_device_registration_hostname_comparison_case_insensitive (self ):
888+ @patch .object (Device , "skip_push_update_on_save" )
889+ def test_device_registration_hostname_comparison_case_insensitive (
890+ self , mocked_method
891+ ):
885892 """
886893 Test that MAC address comparison is case-insensitive and works
887894 with different formats (colons, dashes, no separators)
888895 """
889896 mac_address = "00:11:22:33:aa:BB"
897+ name = mac_address .replace (":" , "-" )
890898 device = self ._create_device_config (
891899 device_opts = {
892900 "mac_address" : mac_address ,
893- "name" : "configured-hostname" ,
901+ "name" : name ,
894902 "key" : TEST_CONSISTENT_KEY ,
895903 }
896904 )
@@ -902,7 +910,8 @@ def test_device_registration_hostname_comparison_case_insensitive(self):
902910 self .assertEqual (response .status_code , 201 )
903911 device .refresh_from_db ()
904912 # Hostname should not be changed
905- self .assertEqual (device .name , "configured-hostname" )
913+ self .assertEqual (device .name , name )
914+ mocked_method .assert_not_called ()
906915
907916 def test_device_report_status_running (self ):
908917 """
0 commit comments