1
from configobj import ConfigObj
8
from turbogears import testutil
12
from loggerhead.controllers import Root
18
testutil.create_request('/')
19
assert 'loggerhead branches' in cherrypy.response.body[0]
24
branch_name = 'branch'
29
class TestWithSimpleTree(object):
31
self.old_bzrhome = bzrlib.osutils.set_or_unset_env('BZR_HOME', '')
32
self.bzrbranch = tempfile.mkdtemp()
33
branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(
34
self.bzrbranch, force_new_tree=True)
35
tree = branch.bzrdir.open_workingtree()
36
f = open(os.path.join(self.bzrbranch, 'myfilename'), 'w')
37
self.filecontents = 'some\nmultiline\ndata'
39
f.write(self.filecontents)
42
tree.add('myfilename')
43
self.fileid = tree.path2id('myfilename')
44
self.msg = 'a very exciting commit message'
45
self.revid = tree.commit(message=self.msg)
47
ini = config_template%self.bzrbranch
49
config = ConfigObj(ini.splitlines())
50
cherrypy.root = Root(config)
53
shutil.rmtree(self.bzrbranch)
54
bzrlib.osutils.set_or_unset_env('BZR_HOME', self.old_bzrhome)
56
# there are so i can run it with py.test and take advantage of the
58
def setup_method(self, meth):
61
def teardown_method(self, meth):
65
testutil.create_request('/')
66
link = '<a href="/project/branch">branch</a>'
67
assert link in cherrypy.response.body[0]
69
def test_changes(self):
70
testutil.create_request('/project/branch/changes')
71
assert self.msg in cherrypy.response.body[0]
73
def test_annotate(self):
74
testutil.create_request('/project/branch/annotate?'
75
+ 'file_id='+self.fileid)
76
for line in self.filecontents.splitlines():
77
assert line in cherrypy.response.body[0]
79
def test_inventory(self):
80
testutil.create_request('/project/branch/files')
81
assert 'myfilename' in cherrypy.response.body[0]