<s> from mock import Mock , patch <EOL> from ceph_deploy . exc import ExecutableNotFound <EOL> from ceph_deploy . util import packages <EOL> class TestCephIsInstalled ( object ) : <EOL> def test_installed ( self ) : <EOL> with patch ( '<STR_LIT>' ) : <EOL> c = packages . Ceph ( Mock ( ) ) <EOL> assert c . installed is True <EOL> def test_not_installed ( self ) : <EOL> with patch ( '<STR_LIT>' ) as fsystem : <EOL> bad_executable = Mock ( <EOL> side_effect = ExecutableNotFound ( '<STR_LIT:host>' , '<STR_LIT>' ) <EOL> ) <EOL> fsystem . executable_path = bad_executable <EOL> c = packages . Ceph ( Mock ( ) ) <EOL> assert c . installed is False <EOL> class TestCephVersion ( object ) : <EOL> def test_executable_not_found ( self ) : <EOL> with patch ( '<STR_LIT>' ) as fsystem : <EOL> bad_executable = Mock ( <EOL> side_effect = ExecutableNotFound ( '<STR_LIT:host>' , '<STR_LIT>' ) <EOL> ) <EOL> fsystem . executable_path = bad_executable <EOL> c = packages . Ceph ( Mock ( ) ) <EOL> assert c . _get_version_output ( ) == '<STR_LIT>' <EOL> def test_output_is_unusable ( self ) : <EOL> _check = Mock ( return_value = ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> c = packages . Ceph ( Mock ( ) , _check = _check ) <EOL> assert c . _get_version_output ( ) == '<STR_LIT>' <EOL> def test_output_usable ( self ) : <EOL> version = '<STR_LIT>' <EOL> _check = Mock ( return_value = ( version , '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> c = packages . Ceph ( Mock ( ) , _check = _check ) <EOL> assert c . _get_version_output ( ) == '<STR_LIT>' </s>
