本文整理汇总了Python中gitosis.config.GitosisRawConfigParser.add_section方法的典型用法代码示例。如果您正苦于以下问题:Python GitosisRawConfigParser.add_section方法的具体用法?Python GitosisRawConfigParser.add_section怎么用?Python GitosisRawConfigParser.add_section使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitosis.config.GitosisRawConfigParser
的用法示例。
在下文中一共展示了GitosisRawConfigParser.add_section方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_push_inits_no_stdout_spam
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_push_inits_no_stdout_spam():
# git init has a tendency to spew to stdout, and that confuses
# e.g. a git push
tmp = util.maketemp()
cfg = RawConfigParser()
cfg.add_section('gitosis')
repositories = os.path.join(tmp, 'repositories')
os.mkdir(repositories)
cfg.set('gitosis', 'repositories', repositories)
generated = os.path.join(tmp, 'generated')
os.mkdir(generated)
cfg.set('gitosis', 'generate-files-in', generated)
cfg.add_section('group foo')
cfg.set('group foo', 'members', 'jdoe')
cfg.set('group foo', 'writable', 'foo')
old_stdout = os.dup(1)
try:
new_stdout = os.tmpfile()
os.dup2(new_stdout.fileno(), 1)
serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo'",
)
finally:
os.dup2(old_stdout, 1)
os.close(old_stdout)
new_stdout.seek(0)
got = new_stdout.read()
new_stdout.close()
eq(got, '')
eq(os.listdir(repositories), ['foo.git'])
assert os.path.isfile(os.path.join(repositories, 'foo.git', 'HEAD'))
示例2: test_no_notListed
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_no_notListed():
cfg = RawConfigParser()
cfg.add_section('group hackers')
cfg.set('group hackers', 'members', 'wsmith')
gen = group.getMembership(config=cfg, user='jdoe')
eq(gen.next(), 'all')
assert_raises(StopIteration, gen.next)
示例3: test_typo_writeable
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_typo_writeable():
tmp = util.maketemp()
repository.init(os.path.join(tmp, 'foo.git'))
cfg = RawConfigParser()
cfg.add_section('gitosis')
cfg.set('gitosis', 'repositories', tmp)
cfg.add_section('group foo')
cfg.set('group foo', 'members', 'jdoe')
cfg.set('group foo', 'writeable', 'foo')
log = logging.getLogger('gitosis.serve')
buf = StringIO()
handler = logging.StreamHandler(buf)
log.addHandler(handler)
try:
got = serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo'",
)
finally:
log.removeHandler(handler)
eq(got, "git-receive-pack '%s/foo.git'" % tmp)
handler.flush()
eq(
buf.getvalue(),
"""Repository 'foo' config has typo "writeable", should be "writable"
""")
示例4: test_push_inits_subdir_parent_exists
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_push_inits_subdir_parent_exists():
tmp = util.maketemp()
cfg = RawConfigParser()
cfg.add_section('gitosis')
repositories = os.path.join(tmp, 'repositories')
os.mkdir(repositories)
foo = os.path.join(repositories, 'foo')
# silly mode on purpose; not to be touched
os.mkdir(foo, 0751)
cfg.set('gitosis', 'repositories', repositories)
generated = os.path.join(tmp, 'generated')
os.mkdir(generated)
cfg.set('gitosis', 'generate-files-in', generated)
cfg.add_section('group foo')
cfg.set('group foo', 'members', 'jdoe')
cfg.set('group foo', 'writable', 'foo/bar')
serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo/bar.git'",
)
eq(os.listdir(repositories), ['foo'])
util.check_mode(foo, 0751, is_dir=True)
eq(os.listdir(foo), ['bar.git'])
assert os.path.isfile(os.path.join(repositories, 'foo', 'bar.git', 'HEAD'))
示例5: test_write_yes_map
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_write_yes_map():
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "map writable foo/bar", "quux/thud")
assert access.allowed(config=cfg,
user="jdoe", mode="writable", path="foo/bar") == ("repositories", "quux/thud")
示例6: test_write_no_simple_with_readonly
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_write_no_simple_with_readonly():
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "readonly", "foo/bar")
assert access.allowed(cfg,
user="jdoe", mode="writable", path="foo/bar") is None
示例7: test_read_yes_map_with_writable
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_read_yes_map_with_writable():
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "map writable foo/bar", "quux/thud")
assert access.allowed(cfg,
user="jdoe", mode="readonly", path="foo/bar") is None
示例8: test_read_yes_all
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_read_yes_all():
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "@all")
cfg.set("group fooers", "readonly", "foo/bar")
assert access.allowed(cfg,
user="jdoe", mode="readonly", path="foo/bar") == ("repositories", "foo/bar")
示例9: test_base_global_unset
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_base_global_unset():
cfg = GitosisRawConfigParser()
cfg.add_section("gitosis")
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "readonly", "foo xyzzy bar")
assert access.allowed(cfg,
user="jdoe", mode="readonly", path="xyzzy") == ("repositories", "xyzzy")
示例10: test_dotgit
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_dotgit():
# a .git extension is always allowed to be added
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "writable", "foo/bar")
assert access.allowed(cfg,
user="jdoe", mode="writable", path="foo/bar.git") == ("repositories", "foo/bar")
示例11: test_base_local
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_base_local():
cfg = GitosisRawConfigParser()
cfg.add_section("group fooers")
cfg.set("group fooers", "repositories", "some/relative/path")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "map writable foo/bar", "baz/quux/thud")
assert access.allowed(cfg,
user="jdoe", mode="writable", path="foo/bar") == ("some/relative/path", "baz/quux/thud")
示例12: test_no_recurse_loop
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_no_recurse_loop():
cfg = RawConfigParser()
cfg.add_section('group hackers')
cfg.set('group hackers', 'members', '@smackers')
cfg.add_section('group smackers')
cfg.set('group smackers', 'members', '@hackers')
gen = group.getMembership(config=cfg, user='jdoe')
eq(gen.next(), 'all')
assert_raises(StopIteration, gen.next)
示例13: test_base_global_absolute
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_base_global_absolute():
cfg = GitosisRawConfigParser()
cfg.add_section("gitosis")
cfg.set("gitosis", "repositories", "/a/leading/path")
cfg.add_section("group fooers")
cfg.set("group fooers", "members", "jdoe")
cfg.set("group fooers", "map writable foo/bar", "baz/quux/thud")
assert access.allowed(cfg,
user="jdoe", mode="writable", path="foo/bar") == ("/a/leading/path", "baz/quux/thud")
示例14: test_projectsList_repoDenied
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_projectsList_repoDenied():
cfg = RawConfigParser()
cfg.add_section("repo foo/bar")
got = StringIO()
gitweb.generate_project_list_fp(config=cfg, fp=got)
eq(
got.getvalue(),
"""\
""",
)
示例15: test_owner_full_access
# 需要导入模块: from gitosis.config import GitosisRawConfigParser [as 别名]
# 或者: from gitosis.config.GitosisRawConfigParser import add_section [as 别名]
def test_owner_full_access():
cfg = GitosisRawConfigParser()
cfg.add_section("repo foo/bar")
cfg.set("repo foo/bar", "owner", "jdoe")
assert access.allowed(cfg,
user="jdoe", mode="writable", path="foo/bar") == ("repositories", "foo/bar")
assert access.allowed(cfg,
user="jdoe", mode="readable", path="foo/bar") == ("repositories", "foo/bar")