@@ -71,6 +71,18 @@ def mock_distro_os_release_attr_return_azure_linux_2(self, attribute):
7171
7272 def mock_distro_os_release_attr_return_none (self , attribute ):
7373 return None
74+
75+ def mock_distro_os_release_attr_return_azure_linux_4 (self , attribute ):
76+ return '4.0.2'
77+
78+ def mock_distro_os_release_attr_return_rhel_10 (self , attribute ):
79+ return '10.0'
80+
81+ def mock_linux_distribution_to_return_azure_linux_4 (self ):
82+ return ['Microsoft Azure Linux' , '4.0' , '' ]
83+
84+ def mock_distro_id_return_rhel (self ):
85+ return 'rhel'
7486 # endregion
7587
7688 def test_get_package_manager (self ):
@@ -139,6 +151,43 @@ def test_platform(self):
139151 self .envlayer .platform .cpu_arch ()
140152 self .envlayer .platform .vm_name ()
141153
154+ def test_get_package_manager_azure_linux_4_not_supported (self ):
155+ """Test that Azure Linux 4 raises an exception"""
156+ self .backup_linux_distribution = self .envlayer .platform .linux_distribution
157+ self .backup_distro_os_release_attr = distro .os_release_attr
158+
159+ platform .system = self .mock_platform_system
160+ self .envlayer .platform .linux_distribution = self .mock_linux_distribution_to_return_azure_linux_4
161+ distro .os_release_attr = self .mock_distro_os_release_attr_return_azure_linux_4
162+
163+ with self .assertRaises (Exception ) as context :
164+ self .envlayer .get_package_manager ()
165+ self .assertEqual (str (context .exception ), "Azure Linux 4 is not yet supported in your region. Please review aka.ms/LinuxPatchExtension for more information." )
166+
167+ # restore
168+ distro .os_release_attr = self .backup_distro_os_release_attr
169+ self .envlayer .platform .linux_distribution = self .backup_linux_distribution
170+
171+ def test_get_package_manager_rhel_10_not_supported (self ):
172+ """Test that RHEL 10 raises an exception"""
173+ self .backup_linux_distribution = self .envlayer .platform .linux_distribution
174+ self .backup_distro_os_release_attr = distro .os_release_attr
175+ self .backup_distro_id = distro .id
176+
177+ platform .system = self .mock_platform_system
178+ self .envlayer .platform .linux_distribution = self .mock_linux_distribution
179+ distro .os_release_attr = self .mock_distro_os_release_attr_return_rhel_10
180+ distro .id = self .mock_distro_id_return_rhel
181+
182+ with self .assertRaises (Exception ) as context :
183+ self .envlayer .get_package_manager ()
184+ self .assertEqual (str (context .exception ), "RHEL 10 is not yet supported in your region. Please review aka.ms/LinuxPatchExtension for more information." )
185+
186+ # restore
187+ distro .id = self .backup_distro_id
188+ distro .os_release_attr = self .backup_distro_os_release_attr
189+ self .envlayer .platform .linux_distribution = self .backup_linux_distribution
190+
142191
143192if __name__ == '__main__' :
144193 unittest .main ()
0 commit comments