Mercurial > bitten > bitten-test
changeset 813:88454000acf8 0.6.x
0.6dev: Merged [890] from trunk.
author | osimons |
---|---|
date | Wed, 15 Sep 2010 10:51:56 +0000 |
parents | f66764964ed2 |
children | f11701cd8b8e |
files | bitten/templates/bitten_config.html bitten/tests/web_ui.py bitten/web_ui.py |
diffstat | 3 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bitten/templates/bitten_config.html +++ b/bitten/templates/bitten_config.html @@ -176,7 +176,7 @@ <th py:for="platform in config.platforms">$platform.name</th> </tr></thead> <tbody py:if="config.builds"> - <tr py:for="rev_num in sorted(config.builds, reverse=True)" + <tr py:for="rev_num in config.revisions" py:with="rev = config.builds[rev_num]"> <th class="chgset" scope="row"> <a href="$rev.href" title="View Changeset">[$rev_num]</a>
--- a/bitten/tests/web_ui.py +++ b/bitten/tests/web_ui.py @@ -104,6 +104,37 @@ self.assertEquals('/trac/attachment/build/test/', data['config']['attachments']['attach_href']) + def test_bitten_keeps_order_of_revisions_from_versioncontrol(self): + # Trac's API specifies that they are sorted chronological (backwards) + # We must not assume that these revision numbers can be sorted later on, + # for example the mercurial plugin will return the revisions as strings + # (e.g. '880:4c19fa95fb9e') + config = BuildConfig(self.env, name='test', path='trunk') + config.insert() + platform = TargetPlatform(self.env, config='test', name='any') + platform.insert() + + PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW') + req = Mock(method='GET', base_path='', cgi_location='', + path_info='/build/'+config.name, href=Href('/trac'), args={}, + chrome={}, authname='joe', + perm=PermissionCache(self.env, 'joe')) + + # revisions are intentionally not sorted in any way - bitten should just keep them! + revision_ids = [5, 8, 2] + revision_list = [('trunk', revision, 'edit') for revision in revision_ids] + root = Mock(get_entries=lambda: ['foo'], get_history=lambda: revision_list) + self.repos = Mock(get_node=lambda path, rev=None: root, + sync=lambda: None, normalize_path=lambda path: path) + self.repos.authz = Mock(has_permission=lambda path: True, assert_permission=lambda path: None) + + module = BuildConfigController(self.env) + assert module.match_request(req) + _, data, _ = module.process_request(req) + + actual_revision_ids = data['config']['revisions'] + self.assertEquals(revision_ids, actual_revision_ids) + def test_view_config_paging(self): config = BuildConfig(self.env, name='test', path='trunk') config.insert()
--- a/bitten/web_ui.py +++ b/bitten/web_ui.py @@ -441,11 +441,14 @@ builds_per_page = 12 * len(platforms) idx = 0 builds = {} + revisions = [] for platform, rev, build in collect_changes(repos, config): if idx >= page * builds_per_page: more = True break elif idx >= (page - 1) * builds_per_page: + if rev not in builds: + revisions.append(rev) builds.setdefault(rev, {}) builds[rev].setdefault('href', req.href.changeset(rev)) if build and build.status != Build.PENDING: @@ -467,6 +470,7 @@ builds[rev][platform.id] = build_data idx += 1 data['config']['builds'] = builds + data['config']['revisions'] = revisions if page > 1: if page == 2: