diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-17 22:58:44 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-18 01:12:22 -0800 |
commit | ec6c4f34913e93ab375d6ed627c126fc9650e411 (patch) | |
tree | 8b4c0b9af74f27ce3a60e7ff696404d8c9cd7ee5 /gitosis | |
parent | Fix bug in mkdir call. (diff) | |
download | gitosis-dakkar-ec6c4f34913e93ab375d6ed627c126fc9650e411.tar.gz gitosis-dakkar-ec6c4f34913e93ab375d6ed627c126fc9650e411.tar.bz2 gitosis-dakkar-ec6c4f34913e93ab375d6ed627c126fc9650e411.zip |
Add tests for _sysfunc and getRepositoryDir.
Diffstat (limited to 'gitosis')
-rw-r--r-- | gitosis/test/test_util.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gitosis/test/test_util.py b/gitosis/test/test_util.py new file mode 100644 index 0000000..3f17cd3 --- /dev/null +++ b/gitosis/test/test_util.py @@ -0,0 +1,46 @@ +from nose.tools import eq_ as eq, assert_raises + +import os +import errno + +from ConfigParser import RawConfigParser + +from gitosis import util + +# Nose interferes with this test case, and 'except' block inside _sysfunc does +# not recieve the error. +#def test_sysfunc_raise_ignore(): +# def foo(): +# os.mkdir('/does/not/exist/anywhere') +# util._sysfunc(foo, [errno.EEXIST]) + +def test_sysfunc_raise_catch(): + def foo(): + raise OSError(errno.EEXIST) + assert_raises(OSError, util._sysfunc, foo, [errno.ENOENT]) + +def test_getRepositoryDir_cfg_missing(): + cfg = RawConfigParser() + d = util.getRepositoryDir(cfg) + eq(d, os.path.expanduser('~/repositories')) + +def test_getRepositoryDir_cfg_empty(): + cfg = RawConfigParser() + cfg.add_section('gitosis') + cfg.set('gitosis', 'repositories', '') + d = util.getRepositoryDir(cfg) + eq(d, os.path.expanduser('~/')) + +def test_getRepositoryDir_cfg_relative(): + cfg = RawConfigParser() + cfg.add_section('gitosis') + cfg.set('gitosis', 'repositories', 'foobar') + d = util.getRepositoryDir(cfg) + eq(d, os.path.expanduser('~/foobar')) + +def test_getRepositoryDir_cfg_absolute(): + cfg = RawConfigParser() + cfg.add_section('gitosis') + cfg.set('gitosis', 'repositories', '/var/gitroot') + d = util.getRepositoryDir(cfg) + eq(d, '/var/gitroot') |