#NEWLINE# def test_list_pkgs( self ) : #NEWLINE# #INDENT# '\n        Test if it list the packages currently installed as a dict.\n        ' #NEWLINE# mock_run = MagicMock ( return_value = 'A\t B\t SAME' ) #NEWLINE# mock_ret = MagicMock ( return_value = True ) #NEWLINE# mock_pkg = MagicMock ( return_value = '' ) #NEWLINE# with patch . dict ( pkgutil . __salt__ , { #NEWLINE# #INDENT# 'cmd.run_stdout' : mock_run , #NEWLINE# 'cmd.retcode' : mock_pkg , #NEWLINE# 'pkg_resource.stringify' : mock_pkg , #NEWLINE# 'pkg_resource.sort_pkglist' : mock_pkg , #NEWLINE# 'cmd.run' : mock_run , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( pkgutil . __context__ , { #NEWLINE# #INDENT# 'pkg.list_pkgs' : mock_ret , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( pkgutil . list_pkgs ( versions_as_list = True , removed = True ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# self . assertDictEqual ( pkgutil . list_pkgs ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# with patch . dict ( pkgutil . __context__ , { #NEWLINE# #INDENT# 'pkg.list_pkgs' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertTrue ( pkgutil . list_pkgs ( versions_as_list = True ) ) #NEWLINE# mock_pkg = MagicMock ( return_value = True ) #NEWLINE# with patch . dict ( pkgutil . __salt__ , { #NEWLINE# #INDENT# 'pkg_resource.stringify' : mock_pkg , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertTrue ( pkgutil . list_pkgs ( ) )