diff MoinMoin/_tests/test_wikiutil.py @ 2704:c6b5c2d813b6

fix AbsPageName(), add tests for it
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 21 Aug 2007 15:45:24 +0200
parents a7dc3cc36362
children 4a4d84273ae1 7bfe80df6772
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Tue Aug 21 13:09:07 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Tue Aug 21 15:45:24 2007 +0200
@@ -733,4 +733,25 @@
         encoded = wikiutil.anchor_name_from_text(text)
         assert expected == encoded
 
+class TestRelativeTools:
+    def test_abs_pagename(self):
+        tests = [
+            # test                      expected output
+            # CHILD_PREFIX
+            (('MainPage', '/SubPage1'), 'MainPage/SubPage1'),
+            (('MainPage', '/SubPage1/SubPage2'), 'MainPage/SubPage1/SubPage2'),
+            (('MainPage/SubPage1', '/SubPage2/SubPage3'), 'MainPage/SubPage1/SubPage2/SubPage3'),
+            (('', '/OtherMainPage'), 'OtherMainPage'), # strange
+            # PARENT_PREFIX
+            (('MainPage/SubPage', '../SisterPage'), 'MainPage/SisterPage'),
+            (('MainPage/SubPage1/SubPage2', '../SisterPage'), 'MainPage/SubPage1/SisterPage'),
+            (('MainPage/SubPage1/SubPage2', '../../SisterPage'), 'MainPage/SisterPage'),
+            (('MainPage', '../SisterPage'), 'SisterPage'), # strange
+        ]
+        for test, expected in tests:
+            yield self._check_abs_pagename, test, expected
+
+    def _check_abs_pagename(self, test, expected):
+        assert expected == wikiutil.AbsPageName(None, *test)
+
 coverage_modules = ['MoinMoin.wikiutil']