Products.CMFPlone/plip-1486-redirection: Add test for existing alias name

Stephan Klinger <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: Products.CMFPlone
Branch: refs/heads/plip-1486-redirection
Date: 2017-07-10T09:31:40+03:00
Author: Stephan Klinger (staeff) <[email protected]>
Commit: https://github.com/plone/Products.CMFPlone/commit/61743c7b3343fef0c2a897986707687ef0783e93

Add test for existing alias name

Files changed:
M Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_redirection.py

diff --git a/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_redirection.py b/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_redirection.py
index 8ce10ce26..535798959 100644
--- a/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_redirection.py
+++ b/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_redirection.py
@@ -12,7 +12,7 @@
     PRODUCTS_CMFPLONE_FUNCTIONAL_TESTING
 
 import unittest
-
+import transaction
 
 class RedirectionControlPanelFunctionalTest(unittest.TestCase):
     """Test that changes in the mail control panel are actually
@@ -113,3 +113,29 @@ def test_redirection_controlpanel_batching(self):
         # Test that view/batching returns batching with anchor in urls
         batching = view.batching()
         self.assertIn('?b_start:int=990#manage-existing-aliases', batching)
+
+    def test_redirection_controlpanel_redirect_alias_exists(self):
+        path_alias = '/alias'
+        path_target = '/test-folder'
+        storage_alias = '/plone{0}'.format(path_alias)
+        storage_target = '/plone{0}'.format(path_target)
+        storage = getUtility(IRedirectionStorage)
+        storage.add(storage_alias, storage_target)
+        transaction.commit()
+
+        self.browser.open(
+            "%s/@@redirection-controlpanel" % self.portal_url)
+        self.browser.getControl(
+            name='redirection').value = path_alias
+        self.browser.getControl(
+            name='target_path').value = path_target
+        self.browser.getControl(name='form.button.Add').click()
+
+        self.assertTrue(
+            storage.get(storage_alias) == storage_target,
+            '{0} not target of alias!'.format(storage_target)
+        )
+        self.assertTrue(
+            'The provided alias already exists!' in self.browser.contents,
+            u'Message "alias already exists" not in page!'
+        )



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.