コード例 #1
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #2
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #3
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #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)
コード例 #5
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #6
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #7
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #8
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)
コード例 #9
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #10
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)
コード例 #11
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)
コード例 #12
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)
コード例 #13
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)
コード例 #14
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #15
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)
コード例 #16
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)
コード例 #17
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)
コード例 #18
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #19
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)
コード例 #20
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #21
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)
コード例 #22
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)
コード例 #23
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)
コード例 #24
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
コード例 #25
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)
コード例 #26
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #27
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #28
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #29
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 def testIsSelectedItemHasPageIdNoParamsPageHasSameIdNoParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hello")
     result = item.isSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
コード例 #30
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 def testIsSelectedItemHasPageIdAndParamsPageHasNoIdAndParams(self):
     item = NavigatorItem(pageId="hello", params={"text": "bonjour"})
     page = self.getPage(None, {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
コード例 #31
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)
コード例 #32
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 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)
コード例 #33
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)
コード例 #34
0
 def testIsSelectedItemHasPageIdNoParamsPageHasSameIdNoParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hello")
     result = item.isSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)
コード例 #35
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 def testIsSelectedItemHasPageIdNoParamsPageHasDifferentIdAndParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hej", {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
コード例 #36
0
 def testIsSelectedItemHasPageIdNoParamsPageHasDifferentIdAndParams(self):
     item = NavigatorItem(pageId="hello")
     page = self.getPage("hej", {"param": "param"})
     result = item.isSelected(page)
     expectedResult = False
     self.assertEqual(expectedResult, result)
コード例 #37
0
ファイル: navigatortest.py プロジェクト: hicksjduk/sehicl
 def testIsSelectedItemHasPageIdAndParamsPageHasSameIdAndExtraParams(self):
     item = NavigatorItem(pageId="hello", params={"text": "bonjour"})
     page = self.getPage("hello", {"param": "param", "text": "bonjour"})
     result = item.isSelected(page)
     expectedResult = True
     self.assertEqual(expectedResult, result)