Beispiel #1
0
 def testGetHtmlItemHasContainedItemsIncludesSelected(self):
     subSubItem = NavigatorItem(pageId="asdgasgsa", text="Sub-sub-item")
     subItems = []
     subItems.append(
         NavigatorItem(pageId="aasaassasa",
                       text="Sub-item 1",
                       items=[subSubItem]))
     subItems.append(NavigatorItem(pageId="asasdasfa", text="Sub-item 2"))
     item = NavigatorItem(pageId="hello",
                          text="Hello",
                          params={"hello": 0},
                          items=subItems)
     page = self.getPage("asdgasgsa", {"session": "12412"})
     result = item.getHtml(page)
     expectedResult = """
     <li>
         <a href="/cgi-bin/page.py?id=hello&session=12412&hello=0">Hello</a>
         <ul id="currentMenu">
             <li>
                 <a href="/cgi-bin/page.py?id=aasaassasa&session=12412">Sub-item 1</a>
                 <ul id="currentMenu">
                     <li>
                         <span class="current">Sub-sub-item</span>
                     </li>
                 </ul>
             </li>
             <li>
                 <a href="/cgi-bin/page.py?id=asasdasfa&session=12412">Sub-item 2</a>
             </li>
         </ul>
     </li>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #2
0
 def testContainsSelectedItemIsNotSelectedAndHasNoIdAndHasNoMatchingItems(
         self):
     items = [NavigatorItem(pageId="asfsdf"), NavigatorItem(pageId="aaaaa")]
     item = NavigatorItem(pageId="sagsd",
                          params={"text": "bonjour"},
                          items=items)
     page = self.getPage("hello", {"param": "param", "text": "bonjour"})
     result = item.containsSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
Beispiel #3
0
 def testContainsSelectedItemIsNotSelectedAndHasAnIdThatDoesNotMatchPageAndHasAMatchingItem(
         self):
     items = [
         NavigatorItem(pageId="asfsdf"),
         NavigatorItem(pageId="aaaaa"),
         NavigatorItem("hello")
     ]
     item = NavigatorItem(itemId="fixtures",
                          pageId="sagsd",
                          params={"text": "bonjour"},
                          items=items)
     page = self.getPage("hello", {"param": "param", "text": "bonjour"})
     result = item.containsSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
Beispiel #4
0
 def testIsSelectedItemHasPageIdAndParamsPageHasSameIdAndDifferentParams(
         self):
     item = NavigatorItem(pageId="hello", params={"text": "bonjour"})
     page = self.getPage("hello", {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
Beispiel #5
0
 def testGetItemLinkItemIsNotCurrentUrlIsSpecified(self):
     item = NavigatorItem(url="http://sehicl.org.uk", text="Home")
     page = self.getPage("goodbye", {"session": 53436})
     result = item.getItemLink(page)
     expectedResult = """
     <a href="http://sehicl.org.uk" target="_blank">Home</a>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #6
0
 def testGetItemLinkItemIsNotCurrentNoSession(self):
     item = NavigatorItem(pageId="hello", text="Home")
     page = self.getPage("goodbye")
     result = item.getItemLink(page)
     expectedResult = """
     <a href="/cgi-bin/page.py?id=hello">Home</a>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #7
0
 def testGetItemLinkItemIsCurrent(self):
     item = NavigatorItem(pageId="hello", text="Home")
     page = self.getPage("hello")
     result = item.getItemLink(page)
     expectedResult = """
     <span class="current">Home</span>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #8
0
 def testGetItemLinkItemIsNotCurrentWithSession(self):
     item = NavigatorItem(pageId="hello", text="Home", params={"hello": 0})
     page = self.getPage("goodbye", {"session": 53436})
     result = item.getItemLink(page)
     expectedResult = """
     <a href="/cgi-bin/page.py?id=hello&session=53436&hello=0">Home</a>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #9
0
 def testContainsSelectedItemIsNotSelectedAndHasAnIdThatDoesNotMatchPageAndHasNoItems(
         self):
     item = NavigatorItem(itemId="fixtures",
                          pageId="sagsd",
                          params={"text": "bonjour"})
     page = self.getPage("hello", {"param": "param", "text": "bonjour"})
     result = item.containsSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
Beispiel #10
0
 def testGetHtmlItemIsCurrentHasNoContainedItems(self):
     item = NavigatorItem(pageId="hello", text="Hello", params={"hello": 0})
     page = self.getPage("hello", {"hello": 0})
     result = item.getHtml(page)
     expectedResult = """
     <li>
         <span class="current">Hello</span>
     </li>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #11
0
 def testGetHtmlItemIsNotCurrentHasNoContainedItemsNoSession(self):
     item = NavigatorItem(pageId="hello", text="Hello", params={"hello": 0})
     page = self.getPage("afaasfsa")
     result = item.getHtml(page)
     expectedResult = """
     <li>
         <a href="/cgi-bin/page.py?id=hello&hello=0">Hello</a>
     </li>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #12
0
 def testContainsSelectedItemIsNotSelectedAndHasAnIdThatMatchesPage(self):
     item = NavigatorItem(itemId="fixtures",
                          pageId="sagsd",
                          params={"text": "bonjour"})
     page = self.getPage("leagueFixtures", {
         "param": "param",
         "text": "bonjour"
     })
     result = item.containsSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
Beispiel #13
0
 def testGetHtmlItemHasContainedItemsIsSelected(self):
     subItems = []
     subItems.append(NavigatorItem(pageId="aasda", text="Item1"))
     subItems.append(NavigatorItem(pageId="aadsgasgas", text="Item2"))
     item = NavigatorItem(pageId="aadgas",
                          text="Hello",
                          params={"hello": 0},
                          items=subItems)
     page = self.getPage("aadgas", params={"hello": 0, "session": "12412"})
     result = item.getHtml(page)
     expectedResult = """
     <li>
         <span class="current">Hello</span>
         <ul id="currentMenu">
             <li>
                 <a href="/cgi-bin/page.py?id=aasda&session=12412">Item1</a>
             </li>
             <li>
                 <a href="/cgi-bin/page.py?id=aadsgasgas&session=12412">Item2</a>
             </li>
         </ul>
     </li>
     """
     self.assertMultiLineEqual(expectedResult, result)
Beispiel #14
0
 def getItem(self, itemElement):
     itemId = itemElement.get("id", None)
     pageId = itemElement.get("pageId", None)
     text = itemElement.text
     if text is not None:
         text = strip(text)
         if text == "":
             text = None
     url = itemElement.get("url")
     params = {}
     for k in itemElement.keys():
         if k not in ("pageId", "url", "id"):
             params[k] = itemElement.get(k)
     items = self.getItems(itemElement)
     answer = NavigatorItem(itemId=itemId,
                            pageId=pageId,
                            params=params,
                            text=text,
                            items=items,
                            url=url)
     return answer
Beispiel #15
0
 def testIsSelectedItemHasPageIdNoParamsPageHasDifferentIdAndParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hej", {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
Beispiel #16
0
 def testIsSelectedItemHasNoPageIdNoParamsPageHasIdAndParams(self):
     item = NavigatorItem(url="http://sehicl.org.uk")
     page = self.getPage("hello", {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
Beispiel #17
0
 def testContainsSelectedItemIsSelected(self):
     item = NavigatorItem(pageId="hello", params={"text": "bonjour"})
     page = self.getPage("hello", {"param": "param", "text": "bonjour"})
     result = item.containsSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
Beispiel #18
0
 def testIsSelectedItemHasPageIdNoParamsPageHasSameIdNoParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hello")
     result = item.isSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
Beispiel #19
0
 def testIsSelectedItemHasPageIdAndParamsPageHasNoIdNoParams(self):
     item = NavigatorItem(pageId="hello", params={"text": "bonjour"})
     page = self.getPage(None)
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)