~divmod-dev/divmod.org/1304710-storeless-adapter

« back to all changes in this revision

Viewing changes to Mantissa/xmantissa/test/test_webnav.py

  • Committer: glyph
  • Date: 2005-07-28 22:09:16 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:2
move this repository to a more official-looking URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2005 Divmod, Inc.  See LICENSE file for details
 
2
 
 
3
from twisted.trial import unittest
 
4
 
 
5
from xmantissa import webnav
 
6
from xmantissa.ixmantissa import INavigableElement
 
7
 
 
8
class FakeNavigator1(object):
 
9
    def getTabs(self):
 
10
        return [webnav.Tab('Hello', INavigableElement, 1.,
 
11
                           [webnav.Tab('Super', None, 1.0),
 
12
                            webnav.Tab('Mega', None, 0.5)])]
 
13
 
 
14
class FakeNavigator2(object):
 
15
    def getTabs(self):
 
16
        return [webnav.Tab('Hello', INavigableElement, 1.,
 
17
                           [webnav.Tab('Ultra', None, 0.75),
 
18
                            webnav.Tab('Hyper', None, 0.25)]),
 
19
                webnav.Tab('Goodbye', None, 0.9)]
 
20
 
 
21
class NavConfig(unittest.TestCase):
 
22
 
 
23
    avatarDomain = 'nav.example.com'
 
24
 
 
25
    def testTabMerge(self):
 
26
        nav = webnav.getTabs([FakeNavigator1(),
 
27
                              FakeNavigator2()])
 
28
 
 
29
        self.assertEquals(
 
30
            nav.children[0].name, 'Hello')
 
31
        self.assertEquals(
 
32
            nav.children[1].name, 'Goodbye')
 
33
 
 
34
        kids = [x.name for x in nav.children[0].children]
 
35
        self.assertEquals(kids, ['Super', 'Ultra', 'Mega', 'Hyper'])