<s> from mock import call <EOL> from nose . tools import istest <EOL> from provy . more . centos import YumRole , GitRole <EOL> from tests . unit . tools . helpers import ProvyTestCase <EOL> class GitRoleTest ( ProvyTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( GitRoleTest , self ) . setUp ( ) <EOL> self . role = GitRole ( prov = None , context = { } ) <EOL> @ istest <EOL> def ensures_a_repository_is_cloned_as_sudo ( self ) : <EOL> with self . execute_mock ( ) as execute : <EOL> self . role . ensure_repository ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> execute . assert_called_with ( '<STR_LIT>' , sudo = True , stdout = False , user = None ) <EOL> @ istest <EOL> def ensures_a_repository_is_cloned_as_non_sudo ( self ) : <EOL> with self . execute_mock ( ) as execute : <EOL> self . role . ensure_repository ( '<STR_LIT>' , '<STR_LIT>' , sudo = False ) <EOL> execute . assert_called_with ( '<STR_LIT>' , sudo = False , stdout = False , user = None ) <EOL> @ istest <EOL> def ensures_a_repository_is_cloned_as_specific_user ( self ) : <EOL> with self . execute_mock ( ) as execute , self . mock_role_method ( '<STR_LIT>' ) as change_path_owner : <EOL> self . role . ensure_repository ( '<STR_LIT>' , '<STR_LIT>' , owner = '<STR_LIT>' , sudo = False ) <EOL> execute . assert_called_with ( '<STR_LIT>' , sudo = False , stdout = False , user = '<STR_LIT>' ) <EOL> change_path_owner . assert_called_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ istest <EOL> def installs_necessary_packages_to_provision ( self ) : <EOL> with self . using_stub ( YumRole ) as yum : <EOL> self . role . provision ( ) <EOL> yum . ensure_up_to_date . assert_called_once_with ( ) <EOL> yum . ensure_package_installed . assert_called_once_with ( '<STR_LIT>' ) <EOL> @ istest <EOL> def ensures_a_branch_is_checked_out_if_needed ( self ) : <EOL> sudo = '<STR_LIT>' <EOL> owner = '<STR_LIT>' <EOL> branch = '<STR_LIT>' <EOL> with self . mock_role_methods ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . role . remote_exists_dir . return_value = True <EOL> self . role . execute . return_value = '<STR_LIT>' <EOL> self . role . ensure_repository ( '<STR_LIT>' , '<STR_LIT>' , sudo = sudo , branch = branch , owner = owner ) <EOL> self . assertEqual ( self . role . execute . mock_calls , [ <EOL> call ( '<STR_LIT>' , sudo = True , stdout = False ) , <EOL> call ( '<STR_LIT>' , sudo = sudo , user = owner ) , <EOL> ] ) </s>
