aboutsummaryrefslogtreecommitdiff
path: root/gitosis/test/test_repository.py
blob: 7e5885d39884b29a5eec8ba005eee54b3e448ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from nose.tools import eq_ as eq
 
import os
import stat
import shutil
 
from gitosis import repository
 
from gitosis.test.util import mkdirmaketempreadFile
 
def check_bare(path):
    # we want it to be a bare repository 
    assert not os.path.exists(os.path.join(path'.git'))
 
def test_init_simple():
    tmp = maketemp()
    path = os.path.join(tmp'repo.git')
    repository.init(path)
    st = os.stat(path)
    assert stat.S_ISDIR(st.st_mode)
    eq(stat.S_IMODE(st.st_mode)0750)
    check_bare(path)
 
def test_init_exist_dir():
    tmp = maketemp()
    path = os.path.join(tmp'repo.git')
    mkdir(path)
    repository.init(path)
    st = os.stat(path)
    assert stat.S_ISDIR(st.st_mode)
    eq(stat.S_IMODE(st.st_mode)0750)
    check_bare(path)
 
def test_init_exist_git():
    tmp = maketemp()
    path = os.path.join(tmp'repo.git')
    repository.init(path)
    repository.init(path)
    st = os.stat(path)
    assert stat.S_ISDIR(st.st_mode)
    eq(stat.S_IMODE(st.st_mode)0750)
    check_bare(path)
 
def test_init_templates():
    tmp = maketemp()
    path = os.path.join(tmp'repo.git')
    if os.path.exists(path):
        shutil.rmtree(path)
    templatedir = os.path.join(
        os.path.dirname(__file__),
        'mocktemplates',
        )
    repository.init(pathtemplate=templatedir)
    repository.init(path)
    got = readFile(os.path.join(path'no-confusion'))
    eq(got'i should show up\n')
    st = os.stat(os.path.join(path'hooks''post-update'))
    assert stat.S_ISREG(st.st_mode)
    eq('%04o'%stat.S_IMODE(st.st_mode)'%04o'%0755)
    got = readFile(os.path.join(path'hooks''post-update'))
    eq(got'#!/bin/sh\n# i can override standard templates\n')
    # standard templates are there, too 
    assert os.path.isfile(os.path.join(path'hooks''pre-rebase'))