@@ -853,17 +853,29 @@ def __call__(self, pkg, dest, enable_repos, disable_repos):
853853 self .disable_repos = disable_repos
854854 return self .to_return
855855
856+ @unit_tests .mock (system_info , "submgr_enabled_repos" , ["enabled_rhsm_repo" ])
857+ @unit_tests .mock (tool_opts , "enablerepo" , []) # to be changed later in the test
858+ @unit_tests .mock (tool_opts , "disable_submgr" , False ) # to be changed later in the test
856859 @unit_tests .mock (utils , "ask_to_continue" , DumbCallableObject ())
857860 @unit_tests .mock (utils , "download_pkg" , DownloadPkgMocked ())
858861 @unit_tests .mock (utils , "run_subprocess" , RunSubprocessMocked ())
859862 def test_replace_non_rhel_installed_kernel (self ):
863+ # test the use case where RHSM is used for the conversion
860864 version = '4.7.4-200.fc24'
861865 pkghandler .replace_non_rhel_installed_kernel (version )
862866 self .assertEqual (utils .download_pkg .called , 1 )
863867 self .assertEqual (utils .download_pkg .pkg , "kernel-4.7.4-200.fc24" )
868+ self .assertEqual (utils .download_pkg .enable_repos , ["enabled_rhsm_repo" ])
864869 self .assertEqual (utils .run_subprocess .cmd ,
865870 "rpm -i --force --nodeps --replacepkgs %skernel-4.7.4-200.fc24*" % utils .TMP_DIR )
866871
872+ # test the use case where custom repos are used for the conversion
873+ system_info .submgr_enabled_repos = []
874+ tool_opts .disable_submgr = True
875+ tool_opts .enablerepo = ["custom_repo" ]
876+ pkghandler .replace_non_rhel_installed_kernel (version )
877+ self .assertEqual (utils .download_pkg .enable_repos , ["custom_repo" ])
878+
867879 @unit_tests .mock (utils , "ask_to_continue" , DumbCallableObject ())
868880 @unit_tests .mock (utils , "download_pkg" , DownloadPkgMocked ())
869881 @unit_tests .mock (utils , "run_subprocess" , RunSubprocessMocked ())
0 commit comments