Mercurial > bitten > bitten-test
annotate bitten/tests/web_ui.py @ 458:c9ac97df8a5e
Fix build listener invocation.
author | cmlenz |
---|---|
date | Wed, 19 Sep 2007 09:32:18 +0000 |
parents | e660687ac89c |
children | a7c795920c4a |
rev | line source |
---|---|
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
2 # |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
3 # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de> |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
4 # Copyright (C) 2007 Edgewall Software |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
5 # All rights reserved. |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
6 # |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
7 # This software is licensed as described in the file COPYING, which |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
8 # you should have received as part of this distribution. The terms |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
9 # are also available at http://bitten.edgewall.org/wiki/License. |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
10 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
11 import shutil |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
12 import tempfile |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
13 import unittest |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
14 |
439 | 15 from trac.core import TracError |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
16 from trac.db import DatabaseManager |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
17 from trac.perm import PermissionCache, PermissionSystem |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
18 from trac.test import EnvironmentStub, Mock |
439 | 19 from trac.util.html import Markup |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
20 from trac.web.clearsilver import HDFWrapper |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
21 from trac.web.href import Href |
439 | 22 from bitten.main import BuildSystem |
23 from bitten.model import Build, BuildConfig, BuildStep, TargetPlatform, schema | |
24 from bitten.web_ui import BuildConfigController, SourceFileLinkFormatter | |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
25 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
26 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
27 class BuildConfigControllerTestCase(unittest.TestCase): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
28 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
29 def setUp(self): |
458 | 30 self.env = EnvironmentStub(enable=['trac.*', 'bitten.*']) |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
31 self.env.path = tempfile.mkdtemp() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
32 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
33 # Create tables |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
34 db = self.env.get_db_cnx() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
35 cursor = db.cursor() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
36 connector, _ = DatabaseManager(self.env)._get_connector() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
37 for table in schema: |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
38 for stmt in connector.to_sql(table): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
39 cursor.execute(stmt) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
40 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
41 # Set up permissions |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
42 self.env.config.set('trac', 'permission_store', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
43 'DefaultPermissionStore') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
44 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
45 # Hook up a dummy repository |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
46 self.repos = Mock( |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
47 get_node=lambda path, rev=None: Mock(get_history=lambda: [], |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
48 isdir=True), |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
49 normalize_path=lambda path: path, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
50 sync=lambda: None |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
51 ) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
52 self.env.get_repository = lambda authname=None: self.repos |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
53 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
54 def tearDown(self): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
55 shutil.rmtree(self.env.path) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
56 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
57 def test_overview(self): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
58 PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
59 req = Mock(method='GET', base_path='', cgi_location='', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
60 path_info='/build', href=Href('/trac'), args={}, chrome={}, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
61 hdf=HDFWrapper(), perm=PermissionCache(self.env, 'joe')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
62 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
63 module = BuildConfigController(self.env) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
64 assert module.match_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
65 module.process_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
66 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
67 self.assertEqual('overview', req.hdf['page.mode']) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
68 self.assertEqual('0', req.hdf.get('build.can_create', '0')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
69 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
70 def test_view_config(self): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
71 config = BuildConfig(self.env, name='test', path='trunk') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
72 config.insert() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
73 platform = TargetPlatform(self.env, config='test', name='any') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
74 platform.insert() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
75 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
76 PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
77 req = Mock(method='GET', base_path='', cgi_location='', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
78 path_info='/build/test', href=Href('/trac'), args={}, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
79 chrome={}, hdf=HDFWrapper(), authname='joe', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
80 perm=PermissionCache(self.env, 'joe')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
81 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
82 root = Mock(get_entries=lambda: ['foo'], |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
83 get_history=lambda: [('trunk', rev, 'edit') for rev in |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
84 range(123, 111, -1)]) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
85 self.repos = Mock(get_node=lambda path, rev=None: root, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
86 sync=lambda: None, normalize_path=lambda path: path) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
87 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
88 module = BuildConfigController(self.env) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
89 assert module.match_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
90 module.process_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
91 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
92 self.assertEqual('view_config', req.hdf['page.mode']) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
93 self.assertEqual('0', req.hdf.get('build.config.can_delete', '0')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
94 self.assertEqual('0', req.hdf.get('build.config.can_modify', '0')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
95 self.assertEqual(None, req.hdf.get('chrome.links.next.0.href')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
96 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
97 def test_view_config_paging(self): |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
98 config = BuildConfig(self.env, name='test', path='trunk') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
99 config.insert() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
100 platform = TargetPlatform(self.env, config='test', name='any') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
101 platform.insert() |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
102 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
103 PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW') |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
104 req = Mock(method='GET', base_path='', cgi_location='', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
105 path_info='/build/test', href=Href('/trac'), args={}, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
106 chrome={}, hdf=HDFWrapper(), authname='joe', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
107 perm=PermissionCache(self.env, 'joe')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
108 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
109 root = Mock(get_entries=lambda: ['foo'], |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
110 get_history=lambda: [('trunk', rev, 'edit') for rev in |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
111 range(123, 110, -1)]) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
112 self.repos = Mock(get_node=lambda path, rev=None: root, |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
113 sync=lambda: None, normalize_path=lambda path: path) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
114 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
115 module = BuildConfigController(self.env) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
116 assert module.match_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
117 module.process_request(req) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
118 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
119 if req.chrome: # Trac 0.11 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
120 self.assertEqual('/trac/build/test?page=2', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
121 req.chrome['links']['next'][0]['href']) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
122 else: |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
123 self.assertEqual('/trac/build/test?page=2', |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
124 req.hdf.get('chrome.links.next.0.href')) |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
125 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
126 |
439 | 127 class SourceFileLinkFormatterTestCase(unittest.TestCase): |
128 | |
129 def setUp(self): | |
458 | 130 self.env = EnvironmentStub(enable=['trac.*', 'bitten.*']) |
439 | 131 |
132 # Create tables | |
133 db = self.env.get_db_cnx() | |
134 cursor = db.cursor() | |
135 connector, _ = DatabaseManager(self.env)._get_connector() | |
136 for table in schema: | |
137 for stmt in connector.to_sql(table): | |
138 cursor.execute(stmt) | |
139 | |
140 # Hook up a dummy repository | |
141 self.repos = Mock( | |
142 get_node=lambda path, rev=None: Mock(get_history=lambda: [], | |
143 isdir=True), | |
144 normalize_path=lambda path: path, | |
145 sync=lambda: None | |
146 ) | |
147 self.env.get_repository = lambda authname=None: self.repos | |
148 | |
149 def tearDown(self): | |
150 pass | |
151 | |
152 def test_format_simple_link_in_repos(self): | |
153 BuildConfig(self.env, name='test', path='trunk').insert() | |
154 build = Build(self.env, config='test', platform=1, rev=123, rev_time=42, | |
155 status=Build.SUCCESS, slave='hal') | |
156 build.insert() | |
157 step = BuildStep(self.env, build=build.id, name='foo', | |
158 status=BuildStep.SUCCESS) | |
159 step.insert() | |
160 | |
161 self.repos.get_node = lambda path, rev: (path, rev) | |
162 | |
163 req = Mock(method='GET', href=Href('/trac'), authname='hal') | |
164 comp = SourceFileLinkFormatter(self.env) | |
165 formatter = comp.get_formatter(req, build) | |
166 | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
167 output = formatter(step, None, None, u'error in foo/bar.c: bad') |
439 | 168 self.assertEqual(Markup, type(output)) |
169 self.assertEqual('error in <a href="/trac/browser/trunk/foo/bar.c">' | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
170 'foo/bar.c</a>: bad', output) |
439 | 171 |
172 def test_format_simple_link_not_in_repos(self): | |
173 BuildConfig(self.env, name='test', path='trunk').insert() | |
174 build = Build(self.env, config='test', platform=1, rev=123, rev_time=42, | |
175 status=Build.SUCCESS, slave='hal') | |
176 build.insert() | |
177 step = BuildStep(self.env, build=build.id, name='foo', | |
178 status=BuildStep.SUCCESS) | |
179 step.insert() | |
180 | |
181 def _raise(): | |
182 raise TracError('No such node') | |
183 self.repos.get_node = lambda path, rev: _raise() | |
184 | |
185 req = Mock(method='GET', href=Href('/trac'), authname='hal') | |
186 comp = SourceFileLinkFormatter(self.env) | |
187 formatter = comp.get_formatter(req, build) | |
188 | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
189 output = formatter(step, None, None, u'error in foo/bar.c: bad') |
439 | 190 self.assertEqual(Markup, type(output)) |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
191 self.assertEqual('error in foo/bar.c: bad', output) |
439 | 192 |
193 def test_format_link_in_repos_with_line(self): | |
194 BuildConfig(self.env, name='test', path='trunk').insert() | |
195 build = Build(self.env, config='test', platform=1, rev=123, rev_time=42, | |
196 status=Build.SUCCESS, slave='hal') | |
197 build.insert() | |
198 step = BuildStep(self.env, build=build.id, name='foo', | |
199 status=BuildStep.SUCCESS) | |
200 step.insert() | |
201 | |
202 self.repos.get_node = lambda path, rev: (path, rev) | |
203 | |
204 req = Mock(method='GET', href=Href('/trac'), authname='hal') | |
205 comp = SourceFileLinkFormatter(self.env) | |
206 formatter = comp.get_formatter(req, build) | |
207 | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
208 output = formatter(step, None, None, u'error in foo/bar.c:123: bad') |
439 | 209 self.assertEqual(Markup, type(output)) |
210 self.assertEqual('error in <a href="/trac/browser/trunk/foo/bar.c#L123">' | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
211 'foo/bar.c:123</a>: bad', output) |
439 | 212 |
213 def test_format_link_not_in_repos_with_line(self): | |
214 BuildConfig(self.env, name='test', path='trunk').insert() | |
215 build = Build(self.env, config='test', platform=1, rev=123, rev_time=42, | |
216 status=Build.SUCCESS, slave='hal') | |
217 build.insert() | |
218 step = BuildStep(self.env, build=build.id, name='foo', | |
219 status=BuildStep.SUCCESS) | |
220 step.insert() | |
221 | |
222 def _raise(): | |
223 raise TracError('No such node') | |
224 self.repos.get_node = lambda path, rev: _raise() | |
225 | |
226 req = Mock(method='GET', href=Href('/trac'), authname='hal') | |
227 comp = SourceFileLinkFormatter(self.env) | |
228 formatter = comp.get_formatter(req, build) | |
229 | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
230 output = formatter(step, None, None, u'error in foo/bar.c:123: bad') |
439 | 231 self.assertEqual(Markup, type(output)) |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
232 self.assertEqual('error in foo/bar.c:123: bad', output) |
439 | 233 |
234 | |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
235 def suite(): |
439 | 236 suite = unittest.TestSuite() |
237 suite.addTest(unittest.makeSuite(BuildConfigControllerTestCase, 'test')) | |
238 suite.addTest(unittest.makeSuite(SourceFileLinkFormatterTestCase, 'test')) | |
239 return suite | |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
240 |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
241 if __name__ == '__main__': |
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
diff
changeset
|
242 unittest.main(defaultTest='suite') |