<s> from __future__ import absolute_import <EOL> from salt . states import mac_assistive as assistive <EOL> from salttesting import TestCase <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import ( <EOL> MagicMock , <EOL> patch <EOL> ) <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> assistive . __salt__ = { } <EOL> class AssistiveTestCase ( TestCase ) : <EOL> def test_installed ( self ) : <EOL> '''<STR_LIT>''' <EOL> expected = { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:result>' : True <EOL> } <EOL> installed_mock = MagicMock ( return_value = False ) <EOL> install_mock = MagicMock ( ) <EOL> with patch . dict ( assistive . __salt__ , { '<STR_LIT>' : installed_mock , <EOL> '<STR_LIT>' : install_mock } ) : <EOL> out = assistive . installed ( '<STR_LIT>' ) <EOL> installed_mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> install_mock . assert_called_once_with ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( out , expected ) <EOL> def test_installed_not_enabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> expected = { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:result>' : True <EOL> } <EOL> installed_mock = MagicMock ( return_value = True ) <EOL> install_mock = MagicMock ( ) <EOL> enabled_mock = MagicMock ( return_value = False ) <EOL> enable_mock = MagicMock ( ) <EOL> with patch . dict ( assistive . __salt__ , { '<STR_LIT>' : installed_mock , <EOL> '<STR_LIT>' : install_mock , <EOL> '<STR_LIT>' : enabled_mock , <EOL> '<STR_LIT>' : enable_mock } ) : <EOL> out = assistive . installed ( '<STR_LIT>' ) <EOL> enabled_mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> enable_mock . assert_called_once_with ( '<STR_LIT>' , True ) <EOL> assert not install_mock . called <EOL> self . assertEqual ( out , expected ) <EOL> def test_installed_enabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> expected = { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:result>' : True <EOL> } <EOL> installed_mock = MagicMock ( return_value = True ) <EOL> install_mock = MagicMock ( ) <EOL> enabled_mock = MagicMock ( return_value = True ) <EOL> enable_mock = MagicMock ( ) <EOL> with patch . dict ( assistive . __salt__ , { '<STR_LIT>' : installed_mock , <EOL> '<STR_LIT>' : install_mock , <EOL> '<STR_LIT>' : enabled_mock , <EOL> '<STR_LIT>' : enable_mock } ) : <EOL> out = assistive . installed ( '<STR_LIT>' ) <EOL> enabled_mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> assert not enable_mock . called <EOL> assert not install_mock . called <EOL> self . assertEqual ( out , expected ) <EOL> def test_installed_not_disabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> expected = { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:result>' : True <EOL> } <EOL> installed_mock = MagicMock ( return_value = True ) <EOL> install_mock = MagicMock ( ) <EOL> enabled_mock = MagicMock ( return_value = True ) <EOL> enable_mock = MagicMock ( ) <EOL> with patch . dict ( assistive . __salt__ , { '<STR_LIT>' : installed_mock , <EOL> '<STR_LIT>' : install_mock , <EOL> '<STR_LIT>' : enabled_mock , <EOL> '<STR_LIT>' : enable_mock } ) : <EOL> out = assistive . installed ( '<STR_LIT>' , False ) <EOL> enabled_mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> enable_mock . assert_called_once_with ( '<STR_LIT>' , False ) <EOL> assert not install_mock . called <EOL> self . assertEqual ( out , expected ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( AssistiveTestCase , needs_daemon = False ) </s>
