Example #1
0
def test_config():
    cfg_file = os.path.join(os.path.dirname(__file__), 'sample.conf')
    no_such_file = os.path.join(os.path.dirname(__file__), 'nosuch.conf')
    git_config_get = partial(git.git_config_get, cfg_file=cfg_file)
    WVPASSEQ(git_config_get(b'bup.foo'), b'bar')
    WVPASSEQ(git_config_get(b'bup.bup'), b'is great')
    WVPASSEQ(git_config_get(b'bup.end'), b'end')
    WVPASSEQ(git_config_get(b'bup.comments'), None)
    WVPASSEQ(git_config_get(b'bup.;comments'), None)
    WVPASSEQ(git_config_get(b'bup.and'), None)
    WVPASSEQ(git_config_get(b'bup.#and'), None)

    WVPASSEQ(git.git_config_get(b'bup.foo', cfg_file=no_such_file), None)

    WVEXCEPT(git.GitError, git_config_get, b'bup.isbad', opttype='bool')
    WVEXCEPT(git.GitError, git_config_get, b'bup.isbad', opttype='int')
    WVPASSEQ(git_config_get(b'bup.isbad'), b'ok')
    WVPASSEQ(True, git_config_get(b'bup.istrue1', opttype='bool'))
    WVPASSEQ(True, git_config_get(b'bup.istrue2', opttype='bool'))
    WVPASSEQ(True, git_config_get(b'bup.istrue3', opttype='bool'))
    WVPASSEQ(False, git_config_get(b'bup.isfalse1', opttype='bool'))
    WVPASSEQ(False, git_config_get(b'bup.isfalse2', opttype='bool'))
    WVPASSEQ(None, git_config_get(b'bup.nosuchkey', opttype='bool'))
    WVPASSEQ(1, git_config_get(b'bup.istrue1', opttype='int'))
    WVPASSEQ(2, git_config_get(b'bup.istrue2', opttype='int'))
    WVPASSEQ(0, git_config_get(b'bup.isfalse2', opttype='int'))
    WVPASSEQ(0x777, git_config_get(b'bup.hex', opttype='int'))
Example #2
0
 def config(self, k, opttype=None):
     assert isinstance(k, bytes)
     return git.git_config_get(k, cfg_file=self.cfg_file, opttype=opttype)
Example #3
0
 def config(self, name, opttype=None):
     val = git.git_config_get(name, opttype=opttype, repo_dir=self.repo_dir)
     if val is None and name == b'bup.dumb-server':
         return os.path.exists(
             git.repo(b'bup-dumb-server', repo_dir=self.repo_dir))
     return val