Esempio n. 1
0
 def testGetItemNoPageTextNoParamsUrlNoSubItems(self):
     xml = """
     <item url="aafafs">A page</item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual(None, result.pageId)
     self.assertEqual("A page", result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 2
0
 def testGetItemPageNoTextNoParamsUrlNoSubItems(self):
     xml = """
     <item pageId="hello" url="aafafs"/>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Hello", result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 3
0
 def testGetItemNoPageNoTextNoParamsNoUrlNoSubItems(self):
     xml = """
     <item/>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual(None, result.pageId)
     self.assertEqual(None, result.text)
     self.assertEqual(None, result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 4
0
 def testGetItemPageTextNoParamsNoUrlNoSubItems(self):
     xml = """
     <item pageId="hello">
         Another page
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Another page", result.text)
     self.assertEqual(None, result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 5
0
 def testGetItemNoPageNoTextParamsUrlNoSubItems(self):
     xml = """
     <item name="Jeremy" surname="Hicks" url="aafafs"/>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual(None, result.pageId)
     self.assertEqual(None, result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({
         "name": "Jeremy",
         "surname": "Hicks"
     }, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 6
0
 def testGetItemPageNoTextParamsNoUrlNoSubItems(self):
     xml = """
     <item pageId="hello" name="Rachel" surname="Hicks"/>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Hello", result.text)
     self.assertEqual(None, result.url)
     self.assertEqual({
         "name": "Rachel",
         "surname": "Hicks"
     }, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 7
0
 def testGetItemNoPageTextNoParamsNoUrlSubItems(self):
     xml = """
     <item>A page
         <item pageId="1"/>
         <item pageId="2"/>
         <item pageId="3"/>
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual(None, result.pageId)
     self.assertEqual("A page", result.text)
     self.assertEqual(None, result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(3, len(result.items))
Esempio n. 8
0
 def testGetItemPageTextNoParamsUrlSubItems(self):
     xml = """
     <item pageId="hello" url="aafafs">
         Another page
         <item pageId="1"/>
         <item pageId="2"/>
         <item pageId="3"/>
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Another page", result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({}, result.pageParams)
     self.assertEqual(3, len(result.items))
Esempio n. 9
0
 def testGetItemPageTextParamsUrlNoSubItems(self):
     xml = """
     <item pageId="hello" name="Jeremy" surname="Hicks" url="aafafs">
         Another page
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Another page", result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({
         "name": "Jeremy",
         "surname": "Hicks"
     }, result.pageParams)
     self.assertEqual(0, len(result.items))
Esempio n. 10
0
 def testGetItemPageNoTextParamsUrlSubItems(self):
     xml = """
     <item pageId="hello" name="Rachel" surname="Hicks" url="aafafs">
         <item pageId="1"/>
         <item pageId="2"/>
         <item pageId="3"/>
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual("hello", result.pageId)
     self.assertEqual("Hello", result.text)
     self.assertEqual("aafafs", result.url)
     self.assertEqual({
         "name": "Rachel",
         "surname": "Hicks"
     }, result.pageParams)
     self.assertEqual(3, len(result.items))
Esempio n. 11
0
 def testGetItemNoPageNoTextParamsNoUrlSubItems(self):
     xml = """
     <item name="Jeremy" surname="Hicks">
         <item pageId="1"/>
         <item pageId="2"/>
         <item pageId="3"/>
     </item>
     """
     element = ElementTree.fromstring(xml)
     result = Navigator().getItem(element)
     self.assertEqual(None, result.pageId)
     self.assertEqual(None, result.text)
     self.assertEqual(None, result.url)
     self.assertEqual({
         "name": "Jeremy",
         "surname": "Hicks"
     }, result.pageParams)
     self.assertEqual(3, len(result.items))
Esempio n. 12
0
 def testGetHtml(self):
     xml = """
     <navigator>
         <item pageId="hello" name="Jeremy" surname="Hicks" url="aafafs">
             Another page
             <item pageId="1">Item 1</item>
             <item pageId="2">Item 2</item>
             <item pageId="3">Item 3</item>
         </item>
         <item pageId="goodbye">Goodbye</item>
     </navigator>
     """
     page = self.getPage("1", {"session": 123})
     result = Navigator(xml).getHtml(page)
     expectedResult = """
     <ul class="navigator">
         <li>
             <a href="aafafs" target="_blank">Another page</a>
             <ul id="currentMenu">
                 <li>
                     <span class="current">Item 1</span>
                 </li>
                 <li>
                     <a href="/cgi-bin/page.py?id=2&session=123">Item 2</a>
                 </li>
                 <li>
                     <a href="/cgi-bin/page.py?id=3&session=123">Item 3</a>
                 </li>
             </ul>
         </li>
         <li>
             <a href="/cgi-bin/page.py?id=goodbye&session=123">Goodbye</a>
         </li>
     </ul>
     """
     self.assertMultiLineEqual(expectedResult, result)
Esempio n. 13
0
 def getNavigator(self):
     navigator = Navigator()
     answer = navigator.getHtml(self)
     return answer