Child: [a404b5] (diff)

Download this file

test_model.py    85 lines (67 with data), 2.6 kB

 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
from unittest import TestCase
from pylons import c, g
import ming
from pyforge import model as M
from pyforge.lib import app_globals
from forgescm.lib import hg, git
import sys
from forgescm import model as FM
from forgescm.tests import TestController
from nose.tools import assert_true
from forgescm.tests import test_helper
ming.configure(**{'ming.main.master':'mongo://localhost:27017/pyforge'})
class EmptyClass(object): pass
class TestRepository(TestCase):
new_fork_mount_point = "new_fork"
def setUp(self):
test_helper.test_setup_app()
test_helper.ensure_c_project_and_app()
# pedantic; testing a test
def test_create_git_repo(self):
result = test_helper.create_git_repo()
assert "commit" in result.output
def test_fork(self):
test_helper.create_git_repo()
test_helper.clone_git_repo(c.app.repo)
c.user = M.User.query.get(username='test_admin')
c.app.repo.fork(c.project._id, self.new_fork_mount_point)
# 1. assert that a new mount point is created
assert_true(c.project.app_instance(self.new_fork_mount_point))
# 2. assert that the message was published
# NYI
def test_hg_init(self):
repo = c.app.repo
repo.type = "hg"
repo.init(dict())
assert repo.status == 'Ready'
# assert web is setup - NYI
# assert commit hook is setup
commit_hook_path = os.path.join(repo.repo_dir,'.hg', 'hgrc')
assert os.path.isfile(commit_hook_path)
def test_svn_init(self):
repo = c.app.repo
repo.type = "svn"
repo.init(dict())
assert repo.status == 'Ready'
# assert web is setup
# assert commit hook is setup
def test_git_init(self):
repo = c.app.repo
repo.type = "git"
readme_path = test_helper.create_readme(repo.repo_dir) # creates a file named README in repo_dir
repo.init(dict())
# the readme we created above should be gone
assert os.path.isfile(readme_path) == False
assert repo.status == 'Ready'
# assert web is setup
gitweb_conf_path = os.path.join(repo.repo_dir, 'gitweb.conf')
assert os.path.isfile(gitweb_conf_path)
# assert commit hook is setup
commit_hook_path = os.path.join(repo.repo_dir,'.git', 'hooks', 'post-receive')
assert os.path.isfile(commit_hook_path)
# this is incomplete, should also have tests
# for each public method in Repository, Commit, Patch
class TestCommit(TestCase):
def setUp(self):
return