Source

moin-2.0 / MoinMoin / apps / frontend / _tests / test_frontend.py

Diff from to

File MoinMoin/apps/frontend/_tests/test_frontend.py

             assert '<html>' in rv.data
             assert '</html>' in rv.data
 
+    def test_wanteds(self):
+        with self.app.test_client() as c:
+            rv = c.get('/+wanteds')
+            assert rv.status == '200 OK'
+            assert rv.headers['Content-Type'] == 'text/html; charset=utf-8'
+            assert '<html>' in rv.data
+            assert '</html>' in rv.data
+
+    def test_orphans(self):
+        with self.app.test_client() as c:
+            rv = c.get('/+orphans')
+            assert rv.status == '200 OK'
+            assert rv.headers['Content-Type'] == 'text/html; charset=utf-8'
+            assert '<html>' in rv.data
+            assert '</html>' in rv.data
+
 class TestUsersettings(object):
     def setup_method(self, method):
         # Save original user
         if not self.user.exists():
             self.user = None
             pytest.skip("Can't create test user")
-
-
-class TestViews(object):
-    """
-    Tester class for +backrefs, +orphans and +wanted views
-    """
-    class DummyItem(object):
-        """
-        Fake storage object, simulating the page item object from the storage
-        """
-        def __init__(self, name, revision):
-            self.latest_revision = revision
-            self.name = name
-
-        def get_revision(self, *args, **kw):
-            return self.latest_revision
-
-    class DummyRevision(object):
-        """
-        Fake revision object, used for retrieving ITEMTRANSCLUSIONS and ITEMLINKS meta
-        """
-        def __init__(self, links, transclusions):
-            self.links = links
-            self.transclusions = transclusions
-
-        def get(self, meta_name, *args, **kw):
-            if meta_name == 'itemlinks':
-                return self.links
-            if meta_name == 'itemtransclusions':
-                return self.transclusions
-
-    def setup_class(self):
-        # list of tuples
-        # (page_name, links, transclusions)
-        items = [('page1', ['page2', 'page3'], ['page2']),
-                 ('page2',  ['page1', 'page3'], []),
-                 ('page3', ['page5'], ['page1']),
-                 ('page4', [], ['page5'])
-                ]
-        # we create the list of items
-        self.items = []
-        for item in items:
-            revision = self.DummyRevision(item[1], item[2])
-            page = self.DummyItem(item[0], revision)
-            self.items.append(page)
-
-    def test_item_sets(self):
-        existing, linked, transcluded, norevs = views._compute_item_sets(self.items)
-        assert sorted(existing) == sorted(['page1', 'page2', 'page3', 'page4'])
-        assert sorted(linked) == sorted(['page1', 'page2', 'page3', 'page5'])
-        assert sorted(transcluded) == sorted(['page1', 'page2', 'page5'])
-        assert sorted(norevs) == []
-
-    def test_backrefs(self):
-        expected_backrefs = sorted(['page1', 'page2'])
-        result_backrefs = sorted(views._backrefs(self.items, 'page3'))
-
-        assert result_backrefs == expected_backrefs
-