[Pkg-mozext-commits] [requestpolicy] 134/257: [tst][ref] import old rules: create TestCase

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:05 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 f6c173f263253d36bbf3a8754786ee1705b1afd6
Author: Martin Kimmerle <dev at 256k.de>
Date:   Mon Nov 16 11:28:03 2015 +0100

    [tst][ref] import old rules: create TestCase
    
    The test case will be also used to test the "oldrules" import
    page.
---
 .../marionette/tests/policy/old_rules/manifest.ini |   2 +-
 .../{test_auto_import.py => test_import.py}        | 111 ++++++++++-----------
 2 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/tests/marionette/tests/policy/old_rules/manifest.ini b/tests/marionette/tests/policy/old_rules/manifest.ini
index 660c619..36c9b9a 100644
--- a/tests/marionette/tests/policy/old_rules/manifest.ini
+++ b/tests/marionette/tests/policy/old_rules/manifest.ini
@@ -1 +1 @@
-[test_auto_import.py]
+[test_import.py]
diff --git a/tests/marionette/tests/policy/old_rules/test_auto_import.py b/tests/marionette/tests/policy/old_rules/test_import.py
similarity index 93%
rename from tests/marionette/tests/policy/old_rules/test_auto_import.py
rename to tests/marionette/tests/policy/old_rules/test_import.py
index c548a2e..417fd70 100644
--- a/tests/marionette/tests/policy/old_rules/test_auto_import.py
+++ b/tests/marionette/tests/policy/old_rules/test_import.py
@@ -13,7 +13,7 @@ PREF_WELCOME_WIN_SHOWN = PREF_PREFIX + "welcomeWindowShown"
 PREF_LAST_RP_VERSION = PREF_PREFIX + "lastVersion"
 
 
-class TestAutomaticRulesImportOnUpgrade(RequestPolicyTestCase):
+class RulesImportTestCase(RequestPolicyTestCase):
 
     def tearDown(self):
         try:
@@ -23,11 +23,58 @@ class TestAutomaticRulesImportOnUpgrade(RequestPolicyTestCase):
                 self.prefs.reset_pref(PREF_PREFIX + pref)
             self.rules.remove_all()
         finally:
-            super(TestAutomaticRulesImportOnUpgrade, self).tearDown()
+            super(RulesImportTestCase, self).tearDown()
 
-    ################
-    # Test Methods #
-    ################
+    @lazyprop
+    def _typical_rules(self):
+        return {
+            "v0": {
+                "allowedOriginsToDestinations": (
+                    "https://www.mozilla.org|https://mozorg.cdn.mozilla.net "
+                    "www.mozilla.org|mozorg.cdn.mozilla.net "
+                    "mozilla.org|mozilla.net"
+                ),
+                "allowedOrigins": (
+                    "https://www.mozilla.org "
+                    "www.mozilla.org "
+                    "mozilla.org"
+                ),
+                "allowedDestinations": (
+                    "https://mozorg.cdn.mozilla.net "
+                    "mozorg.cdn.mozilla.net "
+                    "mozilla.net"
+                )
+            },
+            "expected": [
+                # origin-to-destination rules
+                self._rule({"o": {"s": "https", "h": "*.www.mozilla.org"},
+                            "d": {"s": "https", "h": "*.mozorg.cdn.mozilla.net"}}),
+                self._rule({"o": {"h": "*.www.mozilla.org"},
+                            "d": {"h": "*.mozorg.cdn.mozilla.net"}}),
+                self._rule({"o": {"h": "*.mozilla.org"},
+                            "d": {"h": "*.mozilla.net"}}),
+                # origin rules
+                self._rule({"o": {"s": "https", "h": "*.www.mozilla.org"}}),
+                self._rule({"o": {"h": "*.www.mozilla.org"}}),
+                self._rule({"o": {"h": "*.mozilla.org"}}),
+                # destination rules
+                self._rule({"d": {"s": "https", "h": "*.mozorg.cdn.mozilla.net"}}),
+                self._rule({"d": {"h": "*.mozorg.cdn.mozilla.net"}}),
+                self._rule({"d": {"h": "*.mozilla.net"}})
+            ]
+        }
+
+    def _add_legacy_rules(self, rules):
+        """Add the rules for v0.*.*."""
+
+        for (pref, value) in rules.items():
+            self.prefs.set_pref(PREF_PREFIX + pref, value)
+
+    def _rule(self, rule_data):
+        return self.rules.create_rule(rule_data, allow=True, temp=False)
+
+
+class TestAutomaticRulesImportOnUpgrade(RulesImportTestCase):
 
     def test_autoimport__usual_first_upgrade(self):
         self._test_autoimport_or_not(is_upgrade=True,
@@ -57,7 +104,7 @@ class TestAutomaticRulesImportOnUpgrade(RequestPolicyTestCase):
 
     def _test_autoimport_or_not(self, is_upgrade, with_existing_rules_file,
                                 with_welcomewin, should_autoimport):
-        rules = self.typical_rules
+        rules = self._typical_rules
 
         if with_existing_rules_file:
             # Ensure that a user.json file exists.
@@ -80,55 +127,3 @@ class TestAutomaticRulesImportOnUpgrade(RequestPolicyTestCase):
         if with_welcomewin:
             # Close the setup tab.
             self.browser.tabbar.tabs[-1].close()
-
-    @lazyprop
-    def typical_rules(self):
-        return {
-            "v0": {
-                "allowedOriginsToDestinations": (
-                    "https://www.mozilla.org|https://mozorg.cdn.mozilla.net "
-                    "www.mozilla.org|mozorg.cdn.mozilla.net "
-                    "mozilla.org|mozilla.net"
-                ),
-                "allowedOrigins": (
-                    "https://www.mozilla.org "
-                    "www.mozilla.org "
-                    "mozilla.org"
-                ),
-                "allowedDestinations": (
-                    "https://mozorg.cdn.mozilla.net "
-                    "mozorg.cdn.mozilla.net "
-                    "mozilla.net"
-                )
-            },
-            "expected": [
-                # origin-to-destination rules
-                self._rule({"o": {"s": "https", "h": "*.www.mozilla.org"},
-                            "d": {"s": "https", "h": "*.mozorg.cdn.mozilla.net"}}),
-                self._rule({"o": {"h": "*.www.mozilla.org"},
-                            "d": {"h": "*.mozorg.cdn.mozilla.net"}}),
-                self._rule({"o": {"h": "*.mozilla.org"},
-                            "d": {"h": "*.mozilla.net"}}),
-                # origin rules
-                self._rule({"o": {"s": "https", "h": "*.www.mozilla.org"}}),
-                self._rule({"o": {"h": "*.www.mozilla.org"}}),
-                self._rule({"o": {"h": "*.mozilla.org"}}),
-                # destination rules
-                self._rule({"d": {"s": "https", "h": "*.mozorg.cdn.mozilla.net"}}),
-                self._rule({"d": {"h": "*.mozorg.cdn.mozilla.net"}}),
-                self._rule({"d": {"h": "*.mozilla.net"}})
-            ]
-        }
-
-    ##########################
-    # Private Helper Methods #
-    ##########################
-
-    def _add_legacy_rules(self, rules):
-        """Add the rules for v0.*.*."""
-
-        for (pref, value) in rules.items():
-            self.prefs.set_pref(PREF_PREFIX + pref, value)
-
-    def _rule(self, rule_data):
-        return self.rules.create_rule(rule_data, allow=True, temp=False)

-- 
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