[Pkg-mozext-commits] [requestpolicy] 210/257: [tst][ref] link click redirect: convert subfunctions to methods

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit c3f81fa8a2f0682626ac968c479bba1927ed1ece
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sun Dec 13 17:55:32 2015 +0100

    [tst][ref] link click redirect: convert subfunctions to methods
---
 .../tests/redirections/test_link_click_redirect.py | 101 +++++++++++----------
 1 file changed, 52 insertions(+), 49 deletions(-)

diff --git a/tests/marionette/tests/redirections/test_link_click_redirect.py b/tests/marionette/tests/redirections/test_link_click_redirect.py
index 39287a3..3746e76 100644
--- a/tests/marionette/tests/redirections/test_link_click_redirect.py
+++ b/tests/marionette/tests/redirections/test_link_click_redirect.py
@@ -10,60 +10,63 @@ PREF_DEFAULT_ALLOW = "extensions.requestpolicy.defaultPolicy.allow"
 
 class TestLinkClickRedirect(RequestPolicyTestCase):
 
-    def setUp(self):
-        super(TestLinkClickRedirect, self).setUp()
-
-        self.prefs.set_pref(PREF_DEFAULT_ALLOW, False)
-
     def tearDown(self):
         try:
             self.prefs.reset_pref(PREF_DEFAULT_ALLOW)
         finally:
             super(TestLinkClickRedirect, self).tearDown()
 
-    def test_redirect_notification_appears_or_not(self):
-
-        def test_no_appear(test_url):
-            open_page_and_click_on_first_link(test_url)
-
-            self.assertNotEqual(self.marionette.get_url(), test_url,
-                                "The URL in the urlbar has changed.")
-            self.assertFalse(self.redir.is_shown(),
-                             "There's no redirect notification.")
-
-        def test_appear(test_url):
-            open_page_and_click_on_first_link(test_url)
-
-            self.assertTrue(self.redir.is_shown(),
-                            "The redirect notification has been displayed.")
+    ################
+    # Test Methods #
+    ################
 
-            self.redir.close()
-
-        def open_page_and_click_on_first_link(test_url):
-            with self.marionette.using_context("content"):
-                self.marionette.navigate(test_url)
-                link = self.marionette.find_element("tag name", "a")
-                link.click()
-
-        def get_url(path, generate_page_with_link=True):
-            if generate_page_with_link:
-                path = "link.html?" + path
-            return "http://www.maindomain.test/" + path
-
-
-        test_appear(get_url("redirect-js-document-location-link.html",
-                            generate_page_with_link=False))
-
-        test_appear(get_url("redirect-http-location-header.php"))
-        test_appear(get_url("redirect-http-refresh-header.php"))
-        test_appear(get_url("redirect-js-document-location-auto.html"))
-        test_appear(get_url("redirect-meta-tag-01-immediate.html"))
-        test_appear(get_url("redirect-meta-tag-02-delayed.html"))
-        test_appear(get_url("redirect-meta-tag-03-multiple.html"))
-        test_appear(get_url("redirect-meta-tag-08.html"))
+    def test_r21n_appears_or_not__no_rules(self):
+        self.prefs.set_pref(PREF_DEFAULT_ALLOW, False)
 
-        test_no_appear(get_url("redirect-meta-tag-04-relative-without-slash.html"))
-        test_no_appear(get_url("redirect-meta-tag-05-relative-with-slash.html"))
-        test_no_appear(get_url("redirect-meta-tag-06-different-formatting.html"))
-        test_no_appear(get_url("redirect-meta-tag-07-different-formatting-delayed.html"))
-        test_no_appear(get_url("redirect-meta-tag-09-relative.html"))
+        self._test_appear(self._get_url("redirect-js-document-location-link.html",
+                                        generate_page_with_link=False))
+
+        self._test_appear(self._get_url("redirect-http-location-header.php"))
+        self._test_appear(self._get_url("redirect-http-refresh-header.php"))
+        self._test_appear(self._get_url("redirect-js-document-location-auto.html"))
+        self._test_appear(self._get_url("redirect-meta-tag-01-immediate.html"))
+        self._test_appear(self._get_url("redirect-meta-tag-02-delayed.html"))
+        self._test_appear(self._get_url("redirect-meta-tag-03-multiple.html"))
+        self._test_appear(self._get_url("redirect-meta-tag-08.html"))
+
+        self._test_no_appear(self._get_url("redirect-meta-tag-04-relative-without-slash.html"))
+        self._test_no_appear(self._get_url("redirect-meta-tag-05-relative-with-slash.html"))
+        self._test_no_appear(self._get_url("redirect-meta-tag-06-different-formatting.html"))
+        self._test_no_appear(self._get_url("redirect-meta-tag-07-different-formatting-delayed.html"))
+        self._test_no_appear(self._get_url("redirect-meta-tag-09-relative.html"))
+
+    ##########################
+    # Private Helper Methods #
+    ##########################
+
+    def _test_no_appear(self, test_url):
+        self._open_page_and_click_on_first_link(test_url)
+
+        self.assertNotEqual(self.marionette.get_url(), test_url,
+                            "The URL in the urlbar has changed.")
+        self.assertFalse(self.redir.is_shown(),
+                         "There's no redirect notification.")
+
+    def _test_appear(self, test_url):
+        self._open_page_and_click_on_first_link(test_url)
+
+        self.assertTrue(self.redir.is_shown(),
+                        "The redirect notification has been displayed.")
+
+        self.redir.close()
+
+    def _open_page_and_click_on_first_link(self, test_url):
+        with self.marionette.using_context("content"):
+            self.marionette.navigate(test_url)
+            link = self.marionette.find_element("tag name", "a")
+            link.click()
+
+    def _get_url(self, path, generate_page_with_link=True):
+        if generate_page_with_link:
+            path = "link.html?" + path
+        return "http://www.maindomain.test/" + path

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list