[Pkg-mozext-commits] [requestpolicy] 97/257: [tst][ref] Marionette error detection: rename methods

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:01 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 69b17998dc046188f3b3d56d2f24937ebc1a28fb
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sat Oct 17 01:03:35 2015 +0200

    [tst][ref] Marionette error detection: rename methods
---
 tests/marionette/rp_puppeteer/api/error_detection.py   | 17 +++++++++++------
 .../rp_puppeteer/tests/test_error_detection.py         | 18 +++++++++---------
 tests/marionette/rp_puppeteer/ui/addons.py             |  8 ++++----
 tests/marionette/rp_ui_harness/testcases.py            | 12 ++++++------
 4 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/tests/marionette/rp_puppeteer/api/error_detection.py b/tests/marionette/rp_puppeteer/api/error_detection.py
index 1c8f68c..a0fd56b 100644
--- a/tests/marionette/rp_puppeteer/api/error_detection.py
+++ b/tests/marionette/rp_puppeteer/api/error_detection.py
@@ -17,10 +17,11 @@ class ErrorDetection(BaseLib):
                 Services.obs.notifyObservers(null, "{}", "{}");
                 """.format(topic, data))
 
-    def get_error_count(self):
+    @property
+    def n_errors(self):
         raise NotImplementedError
 
-    def reset_error_count(self):
+    def reset(self):
         raise NotImplementedError
 
     def trigger_error(self):
@@ -28,15 +29,17 @@ class ErrorDetection(BaseLib):
 
 
 class LoggingErrorDetection(ErrorDetection):
+
     def __init__(self, marionette_getter):
         BaseLib.__init__(self, marionette_getter)
 
         self.prefs = Preferences(marionette_getter)
 
-    def get_error_count(self):
+    @property
+    def n_errors(self):
         return self.prefs.get_pref(ERROR_COUNT_PREF)
 
-    def reset_error_count(self):
+    def reset(self):
         self.prefs.set_pref(ERROR_COUNT_PREF, 0)
 
     def trigger_error(self, error_type, msg="[Marionette unit test]"):
@@ -45,7 +48,9 @@ class LoggingErrorDetection(ErrorDetection):
 
 
 class ConsoleErrorDetection(ErrorDetection):
-    def get_error_count(self):
+
+    @property
+    def n_errors(self):
         with self.marionette.using_context("chrome"):
             return self.marionette.execute_script(
                 """
@@ -55,7 +60,7 @@ class ConsoleErrorDetection(ErrorDetection):
                 return scope.ConsoleObserver.getNumErrors();
                 """)
 
-    def reset_error_count(self):
+    def reset(self):
         with self.marionette.using_context("chrome"):
             return self.marionette.execute_script(
                 """
diff --git a/tests/marionette/rp_puppeteer/tests/test_error_detection.py b/tests/marionette/rp_puppeteer/tests/test_error_detection.py
index 2259bb2..aa12ac6 100644
--- a/tests/marionette/rp_puppeteer/tests/test_error_detection.py
+++ b/tests/marionette/rp_puppeteer/tests/test_error_detection.py
@@ -11,35 +11,35 @@ class TestErrorDetection(RequestPolicyTestCase):
     def test_logging_error_detection(self):
         error_detect = LoggingErrorDetection(lambda: self.marionette)
 
-        previous_value = error_detect.get_error_count()
+        previous_value = error_detect.n_errors
 
         self.assertIsNotNone(previous_value,
                              msg="The pref for the error count exists.")
 
         error_detect.trigger_error(
             "warning", msg="[Marionette] test_logging_error_detection")
-        self.assertEqual(error_detect.get_error_count(), previous_value + 1,
+        self.assertEqual(error_detect.n_errors, previous_value + 1,
                          msg="The error has been detected.")
 
         error_detect.trigger_error(
             "severe", msg="[Marionette] test_logging_error_detection")
-        self.assertEqual(error_detect.get_error_count(), previous_value + 2,
+        self.assertEqual(error_detect.n_errors, previous_value + 2,
                          msg="The severe log message has been detected.")
 
-        error_detect.reset_error_count()
-        self.assertEqual(error_detect.get_error_count(), 0,
+        error_detect.reset()
+        self.assertEqual(error_detect.n_errors, 0,
                          msg="The Logging error count has been reset.")
 
     def test_console_error_detection(self):
         error_detect = ConsoleErrorDetection(lambda: self.marionette)
 
-        self.assertEqual(error_detect.get_error_count(), 0,
+        self.assertEqual(error_detect.n_errors, 0,
                          msg="The Console error count is zero.")
 
         error_detect.trigger_error("ReferenceError")
-        self.assertEqual(error_detect.get_error_count(), 1,
+        self.assertEqual(error_detect.n_errors, 1,
                          msg="The Console error count has increased.")
 
-        error_detect.reset_error_count()
-        self.assertEqual(error_detect.get_error_count(), 0,
+        error_detect.reset()
+        self.assertEqual(error_detect.n_errors, 0,
                          msg="The Console error count has been reset.")
diff --git a/tests/marionette/rp_puppeteer/ui/addons.py b/tests/marionette/rp_puppeteer/ui/addons.py
index 4a524ef..4b9fd68 100644
--- a/tests/marionette/rp_puppeteer/ui/addons.py
+++ b/tests/marionette/rp_puppeteer/ui/addons.py
@@ -75,12 +75,12 @@ class RequestPolicy(BaseLib):
 
     @contextmanager
     def _ensure_no_errors(self):
-        logging_errors_before = self.logging_error_detect.get_error_count()
-        console_errors_before = self.console_error_detect.get_error_count()
+        logging_errors_before = self.logging_error_detect.n_errors
+        console_errors_before = self.console_error_detect.n_errors
         yield
-        logging_error_count = (self.logging_error_detect.get_error_count() -
+        logging_error_count = (self.logging_error_detect.n_errors -
                                logging_errors_before)
-        console_error_count = (self.console_error_detect.get_error_count() -
+        console_error_count = (self.console_error_detect.n_errors -
                                console_errors_before)
         if logging_error_count > 0 and console_error_count > 0:
             raise Exception("There have been {} Logging errors and "
diff --git a/tests/marionette/rp_ui_harness/testcases.py b/tests/marionette/rp_ui_harness/testcases.py
index f2cfbb6..0300b42 100644
--- a/tests/marionette/rp_ui_harness/testcases.py
+++ b/tests/marionette/rp_ui_harness/testcases.py
@@ -55,10 +55,10 @@ class RequestPolicyTestCase(RequestPolicyPuppeteer, FirefoxTestCase):
 
     def _check_and_reset_error_counts(self):
         try:
-            self.assertEqual(self.logging_error_detect.get_error_count(), 0,
-                             "The Logging error count is zero.")
-            self.assertEqual(self.console_error_detect.get_error_count(), 0,
-                             "The Console error count is zero.")
+            self.assertEqual(self.logging_error_detect.n_errors, 0,
+                             "There should be no logging errers.")
+            self.assertEqual(self.console_error_detect.n_errors, 0,
+                             "There should be no console errors.")
         finally:
-            self.logging_error_detect.reset_error_count()
-            self.console_error_detect.reset_error_count()
+            self.logging_error_detect.reset()
+            self.console_error_detect.reset()

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