Rev 180: Clean up the test suite. in http://bazaar.launchpad.net/~jameinel/loggerhead/merge_trunk
John Arbash Meinel
john at arbash-meinel.com
Thu Jan 27 22:05:12 UTC 2011
At http://bazaar.launchpad.net/~jameinel/loggerhead/merge_trunk
------------------------------------------------------------
revno: 180
revision-id: john at arbash-meinel.com-20110127220500-v477byd6he25net5
parent: john at arbash-meinel.com-20110127214904-7xu7soji6mu76jib
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge_trunk
timestamp: Thu 2011-01-27 16:05:00 -0600
message:
Clean up the test suite.
The annotate and view uis now take a values dict, rather than
directly taking the file_id, rev_id values. (presumably so we
can avoid recalculating things we already know about).
The test suite, however, was calling things directly, so it
needed to pass in an equivalent structure.
-------------- next part --------------
=== modified file 'loggerhead/controllers/__init__.py'
--- a/loggerhead/controllers/__init__.py 2011-01-11 00:30:17 +0000
+++ b/loggerhead/controllers/__init__.py 2011-01-27 22:05:00 +0000
@@ -151,4 +151,4 @@
def tree_for(self, file_id, revid):
file_revid = self._history.get_inventory(revid)[file_id].revision
- return self._history._branch.repository.revision_tree(file_revid)
\ No newline at end of file
+ return self._history._branch.repository.revision_tree(file_revid)
=== modified file 'loggerhead/controllers/annotate_ui.py'
--- a/loggerhead/controllers/annotate_ui.py 2011-01-27 21:49:04 +0000
+++ b/loggerhead/controllers/annotate_ui.py 2011-01-27 22:05:00 +0000
@@ -24,9 +24,9 @@
def annotate_file(self, info):
file_id = info['file_id']
revid = info['change'].revid
-
+
tree = self.tree_for(file_id, revid)
-
+
change_cache = {}
last_line_revid = None
parity = 1
@@ -46,9 +46,8 @@
yield util.Container(
parity=parity, new_rev=new_rev, change=change)
-
+
def get_values(self, path, kwargs, headers):
values = super(AnnotateUI, self).get_values(path, kwargs, headers)
values['annotated'] = self.annotate_file(values)
-
return values
=== modified file 'loggerhead/tests/test_controllers.py'
--- a/loggerhead/tests/test_controllers.py 2010-05-14 09:10:06 +0000
+++ b/loggerhead/tests/test_controllers.py 2011-01-27 22:05:00 +0000
@@ -61,20 +61,25 @@
def make_annotate_ui_for_file_history(self, file_id, rev_ids_texts):
tree = self.make_branch_and_tree('.')
- open('filename', 'w').write('')
+ self.build_tree_contents([('filename', '')])
tree.add(['filename'], [file_id])
for rev_id, text in rev_ids_texts:
- open('filename', 'w').write(text)
+ self.build_tree_contents([('filename', text)])
tree.commit(rev_id=rev_id, message='.')
tree.branch.lock_read()
self.addCleanup(tree.branch.unlock)
- branch_app = BranchWSGIApp(tree.branch)
+ branch_app = BranchWSGIApp(tree.branch, friendly_name='test_name')
return AnnotateUI(branch_app, branch_app.get_history)
def test_annotate_file(self):
history = [('rev1', 'old\nold\n'), ('rev2', 'new\nold\n')]
ann_ui = self.make_annotate_ui_for_file_history('file_id', history)
- annotated = list(ann_ui.annotate_file('file_id', 'rev2'))
+ # A lot of this state is set up by __call__, but we'll do it directly
+ # here.
+ ann_ui.args = ['rev2']
+ annotate_info = ann_ui.get_values('filename',
+ kwargs={'file_id': 'file_id'}, headers={})
+ annotated = list(annotate_info['annotated'])
self.assertEqual(2, len(annotated))
self.assertEqual('2', annotated[0].change.revno)
self.assertEqual('1', annotated[1].change.revno)
More information about the bazaar-commits
mailing list