Parent: [ec7d70] (diff)

Child: [65b74c] (diff)

Download this file

test_controllers.py    58 lines (45 with data), 1.8 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
import os
import pkg_resources
from pylons import c
from ming.orm import ThreadLocalORMSession
from pyforge.lib import helpers as h
from forgegit.tests import TestController
class TestRootController(TestController):
def setUp(self):
TestController.setUp(self)
h.set_context('test', 'src-git')
repo_dir = pkg_resources.resource_filename(
'forgegit', 'tests/data')
c.app.repo.fs_path = repo_dir
c.app.repo.status = 'ready'
c.app.repo.name = 'testgit.git'
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
def test_index(self):
resp = self.app.get('/src-git/').follow()
assert 'git://' in resp
assert 'ready' in resp
def _get_ci(self):
resp = self.app.get('/src-git/ref/master:/')
for tag in resp.html.findAll('a'):
if tag['href'].startswith('/p/test/src-git/ci/'): break
return tag['href']
def test_commit(self):
ci = self._get_ci()
resp = self.app.get(ci)
assert 'Sebastian' in resp, resp.showbrowser()
def test_tree(self):
ci = self._get_ci()
resp = self.app.get(ci + 'tree/')
assert len(resp.html.findAll('tr')) > 6, resp.showbrowser()
resp = self.app.get(ci + 'tree/doc/')
assert 'roadmap.rst' in resp, resp.showbrowser()
def test_file(self):
ci = self._get_ci()
resp = self.app.get(ci + 'tree/doc/index.rst')
assert 'GitPython' in resp, resp.showbrowser()
def test_diff(self):
ci = self._get_ci()
resp = self.app.get(ci + 'tree/doc/index.rst?diff=501bf602abea7d21c3dbb409b435976e92033145')
assert 'GitPython Documentation' in resp, resp.showbrowser()
assert '+++' in resp, resp.showbrowser()