Skip to content

Commit

Permalink
Extra tests for storage without any slash and with nested paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Feb 13, 2019
1 parent 34b3300 commit c9360e9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plone/app/redirector/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ def test_storage_one_redirect(self):
self.assertFalse(p.has_path('/bar'))
self.assertListEqual(p.redirects('/bar'), ['/foo'])

def test_storage_no_slash(self):
# Standard Plone will created redirects with key
# /plone-site-id/some/path.
# But a slash at the beginning is not mandatory.
p = RedirectionStorage()
self.assertFalse(p.has_path('foo'))
p.add('foo', 'bar')
self.assertTrue(p.has_path('foo'))
self.assertEqual(p.get('foo'), 'bar')
self.assertFalse(p.has_path('bar'))
self.assertListEqual(p.redirects('bar'), ['foo'])

def test_storage_nested(self):
# Since Plone will created redirects with key
# /plone-site-id/some/path, testing with multiple slashes seems wise.
p = RedirectionStorage()
self.assertFalse(p.has_path('/plone/some/path'))
p.add('/plone/some/path', '/plone/a/different/path')
self.assertTrue(p.has_path('/plone/some/path'))
self.assertEqual(p.get('/plone/some/path'), '/plone/a/different/path')
self.assertFalse(p.has_path('/plone/a/different/path'))
self.assertListEqual(p.redirects('/plone/a/different/path'), ['/plone/some/path'])

def test_storage_trailing_slash(self):
# trailing slashes are ignored
p = RedirectionStorage()
Expand Down

0 comments on commit c9360e9

Please sign in to comment.