<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import os <EOL> import logging <EOL> import pwd <EOL> import shutil <EOL> from salttesting import skipIf <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import patch , NO_MOCK , NO_MOCK_REASON <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> import integration <EOL> from salt . fileserver import gitfs <EOL> gitfs . __opts__ = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True <EOL> } <EOL> LOAD = { '<STR_LIT>' : '<STR_LIT>' } <EOL> log = logging . getLogger ( __name__ ) <EOL> try : <EOL> import git <EOL> GITFS_AVAILABLE = True <EOL> except ImportError : <EOL> GITFS_AVAILABLE = False <EOL> if not gitfs . __virtual__ ( ) : <EOL> GITFS_AVAILABLE = False <EOL> @ skipIf ( not GITFS_AVAILABLE , "<STR_LIT>" ) <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class GitFSTest ( integration . ModuleCase ) : <EOL> maxDiff = None <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . integration_base_files = os . path . join ( integration . FILES , '<STR_LIT:file>' , '<STR_LIT>' ) <EOL> self . tmp_repo_dir = os . path . join ( integration . TMP , '<STR_LIT>' ) <EOL> try : <EOL> shutil . copytree ( self . integration_base_files , self . tmp_repo_dir + '<STR_LIT:/>' ) <EOL> except OSError : <EOL> pass <EOL> try : <EOL> repo = git . Repo ( self . tmp_repo_dir ) <EOL> except git . exc . InvalidGitRepositoryError : <EOL> repo = git . Repo . init ( self . tmp_repo_dir ) <EOL> if '<STR_LIT>' not in os . environ : <EOL> try : <EOL> os . environ [ '<STR_LIT>' ] = pwd . getpwuid ( os . geteuid ( ) ) . pw_name <EOL> except AttributeError : <EOL> log . error ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:root>' <EOL> repo . index . add ( [ x for x in os . listdir ( self . tmp_repo_dir ) <EOL> if x != '<STR_LIT>' ] ) <EOL> repo . index . commit ( '<STR_LIT>' ) <EOL> with patch . dict ( gitfs . __opts__ , { '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' + self . tmp_repo_dir ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] } ) : <EOL> gitfs . update ( ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> shutil . rmtree ( self . tmp_repo_dir ) <EOL> shutil . rmtree ( os . path . join ( self . master_opts [ '<STR_LIT>' ] , '<STR_LIT>' ) ) <EOL> def test_file_list ( self ) : <EOL> with patch . dict ( gitfs . __opts__ , { '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' + self . tmp_repo_dir ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] } ) : <EOL> ret = gitfs . file_list ( LOAD ) <EOL> self . assertIn ( '<STR_LIT>' , ret ) <EOL> def test_dir_list ( self ) : <EOL> with patch . dict ( gitfs . __opts__ , { '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' + self . tmp_repo_dir ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] } ) : <EOL> ret = gitfs . dir_list ( LOAD ) <EOL> self . assertIn ( '<STR_LIT>' , ret ) <EOL> def test_envs ( self ) : <EOL> with patch . dict ( gitfs . __opts__ , { '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' + self . tmp_repo_dir ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . master_opts [ '<STR_LIT>' ] } ) : <EOL> ret = gitfs . envs ( ) <EOL> self . assertIn ( '<STR_LIT>' , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> integration . run_tests ( GitFSTest ) </s>
