@@ -19,6 +19,7 @@ def test_get_kernel_hash_from_data(self):
1919
2020
2121
22+
2223class TestContainerDetection :
2324 @patch ('os.path.exists' )
2425 def test_inside_vz_container_true (self , mock_exists ):
@@ -57,20 +58,22 @@ class TestGetDistroInfo:
5758 @patch ('os.path.exists' , return_value = True )
5859 @patch ('builtins.open' , new_callable = mock_open , read_data = 'ID=centos\n VERSION_ID="7"\n ' )
5960 def test_get_distro_info_success (self , mock_file , mock_exists ):
60- name = kc_compat .get_distro_info ()
61+ name , version = kc_compat .get_distro_info ()
6162 assert name == 'centos'
62-
63+ assert version == '7'
6364
6465 @patch ('os.path.exists' , return_value = False )
6566 def test_get_distro_info_no_file (self , mock_exists ):
66- name = kc_compat .get_distro_info ()
67+ name , version = kc_compat .get_distro_info ()
6768 assert name is None
69+ assert version is None
6870
6971 @patch ('os.path.exists' , return_value = True )
7072 @patch ('builtins.open' , side_effect = IOError ("Permission denied" ))
7173 def test_get_distro_info_read_error (self , mock_file , mock_exists ):
72- name = kc_compat .get_distro_info ()
74+ name , version = kc_compat .get_distro_info ()
7375 assert name is None
76+ assert version is None
7477
7578
7679class TestIsDistroSupported :
@@ -149,7 +152,7 @@ def test_main_compatible(self, mock_print, mock_compat, mock_lxc, mock_vz):
149152 @patch .object (kc_compat , 'inside_vz_container' , return_value = False )
150153 @patch .object (kc_compat , 'inside_lxc_container' , return_value = False )
151154 @patch .object (kc_compat , 'is_compat' , return_value = False )
152- @patch .object (kc_compat , 'get_distro_info' , return_value = 'centos' )
155+ @patch .object (kc_compat , 'get_distro_info' , return_value = ( 'centos' , '7' ) )
153156 @patch .object (kc_compat , 'is_distro_supported' , return_value = True )
154157 @patch ('builtins.print' )
155158 def test_main_kernel_not_found_but_distro_supported (self , mock_print , mock_distro_supported ,
@@ -167,7 +170,7 @@ def test_main_kernel_not_found_but_distro_supported(self, mock_print, mock_distr
167170 @patch .object (kc_compat , 'inside_vz_container' , return_value = False )
168171 @patch .object (kc_compat , 'inside_lxc_container' , return_value = False )
169172 @patch .object (kc_compat , 'is_compat' , return_value = False )
170- @patch .object (kc_compat , 'get_distro_info' , return_value = 'unknown' )
173+ @patch .object (kc_compat , 'get_distro_info' , return_value = ( 'unknown' , None ) )
171174 @patch .object (kc_compat , 'is_distro_supported' , return_value = False )
172175 @patch ('builtins.print' )
173176 def test_main_kernel_not_found_distro_not_supported (self , mock_print , mock_distro_supported ,
@@ -192,7 +195,7 @@ def test_main_silent_mode(self, mock_print, mock_compat, mock_lxc, mock_vz):
192195 mock_print .assert_not_called ()
193196
194197 @patch ('sys.argv' , ['kc-compat.py' , '--report' ])
195- @patch .object (kc_compat , 'get_distro_info' , return_value = 'centos' )
198+ @patch .object (kc_compat , 'get_distro_info' , return_value = ( 'centos' , '7' ) )
196199 @patch .object (kc_compat , 'inside_vz_container' , return_value = False )
197200 @patch .object (kc_compat , 'inside_lxc_container' , return_value = False )
198201 @patch .object (kc_compat , 'is_compat' , return_value = True )
@@ -210,7 +213,7 @@ def test_main_report_mode(self, mock_print, mock_file, mock_compat, mock_lxc, mo
210213 assert calls [0 ].args [0 ] == "=== KernelCare Compatibility Report ==="
211214 assert calls [1 ].args [0 ].startswith ("Kernel Hash: " )
212215 assert calls [2 ].args [0 ] == "Distribution: centos"
213- assert calls [3 ].args [0 ] == "Version: Not available "
216+ assert calls [3 ].args [0 ] == "Version: 7 "
214217 assert calls [4 ].args [0 ] == "Kernel: Linux version 5.4.0-test"
215218 assert calls [5 ].args [0 ] == "====================================="
216219 assert calls [6 ].args [0 ] == "COMPATIBLE"
0 commit comments