~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_controllers.py

  • Committer: Michael Hudson
  • Date: 2009-02-18 00:56:51 UTC
  • mfrom: (269.1.8 clean-up-revision-view)
  • Revision ID: michael.hudson@canonical.com-20090218005651-0djjmxad3prwgui7
clean up the revision template and code a bit

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from loggerhead.apps.branch import BranchWSGIApp
2
2
from loggerhead.controllers.inventory_ui import InventoryUI
 
3
from loggerhead.controllers.revision_ui import RevisionUI
3
4
from loggerhead.tests.test_simple import BasicTests
 
5
from loggerhead import util
4
6
 
5
7
 
6
8
class TestInventoryUI(BasicTests):
21
23
        inv = bzrbranch.repository.get_inventory(bzrbranch.last_revision())
22
24
        self.assertEqual(1, len(inv_ui.get_filelist(inv, '')))
23
25
 
 
26
 
 
27
class TestRevisionUI(BasicTests):
 
28
 
 
29
    def make_bzrbranch_and_revision_ui_for_tree_shapes(self, shape1, shape2):
 
30
        tree = self.make_branch_and_tree('.')
 
31
        self.build_tree_contents(shape1)
 
32
        tree.smart_add([])
 
33
        tree.commit('')
 
34
        tree.smart_add([])
 
35
        self.build_tree_contents(shape2)
 
36
        tree.commit('')
 
37
        tree.branch.lock_read()
 
38
        self.addCleanup(tree.branch.unlock)
 
39
        branch_app = BranchWSGIApp(tree.branch)
 
40
        branch_app._environ = {
 
41
            'wsgi.url_scheme':'',
 
42
            'SERVER_NAME':'',
 
43
            'SERVER_PORT':'80',
 
44
            }
 
45
        branch_app._url_base = ''
 
46
        branch_app.friendly_name = ''
 
47
        return tree.branch, RevisionUI(branch_app, branch_app.get_history)
 
48
 
 
49
    def test_get_values(self):
 
50
        branch, rev_ui = self.make_bzrbranch_and_revision_ui_for_tree_shapes(
 
51
            [], [])
 
52
        rev_ui.args = ['2']
 
53
        util.set_context({})
 
54
        self.assertIsInstance(
 
55
            rev_ui.get_values('2', {}, []),
 
56
            dict)