QChris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/155004

Change subject: When testing, stub out replication lag checking
......................................................................

When testing, stub out replication lag checking

Tests effectively checked for replication lag. As “no lag” is the
default situation we're working in, we stub out replication lag
checking to always return “no lag”. Thereby, we're lighter on the
database, and also tests depend less on the database.

Change-Id: I84629cfad3ff3395e386b8542e0466fa2d2b6a00
---
M tests/fixtures.py
M tests/stubs/__init__.py
A tests/stubs/never_lagging_replication_lag_service_stub.py
3 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/analytics/wikimetrics 
refs/changes/04/155004/1

diff --git a/tests/fixtures.py b/tests/fixtures.py
index 1c9a570..973a0e7 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -6,6 +6,7 @@
 from mock import Mock
 from logging import RootLogger, getLogger
 
+from wikimetrics.api import ReplicationLagServiceFactory
 from wikimetrics.utils import (
     parse_date, format_date, parse_pretty_date, format_pretty_date, 
UNICODE_NULL
 )
@@ -26,6 +27,7 @@
     Logging,
     Archive,
 )
+from tests.stubs import NeverLaggingReplicationLagServiceStub
 from wikimetrics.enums import CohortUserRole
 
 mediawiki_project = 'wiki'
@@ -598,6 +600,9 @@
         self.mwSession = db.get_mw_session(mediawiki_project)
         self.mwSession2 = db.get_mw_session(second_mediawiki_project)
         DatabaseTest.tearDown(self)
+        ReplicationLagServiceFactory.force_service_class(
+            NeverLaggingReplicationLagServiceStub
+        )
     
     def tearDown(self):
 
diff --git a/tests/stubs/__init__.py b/tests/stubs/__init__.py
index cf268fd..a6cca4c 100644
--- a/tests/stubs/__init__.py
+++ b/tests/stubs/__init__.py
@@ -1 +1,2 @@
 from always_lagging_replication_lag_service_stub import 
AlwaysLaggingReplicationLagServiceStub
+from never_lagging_replication_lag_service_stub import 
NeverLaggingReplicationLagServiceStub
diff --git a/tests/stubs/never_lagging_replication_lag_service_stub.py 
b/tests/stubs/never_lagging_replication_lag_service_stub.py
new file mode 100644
index 0000000..abae17f
--- /dev/null
+++ b/tests/stubs/never_lagging_replication_lag_service_stub.py
@@ -0,0 +1,7 @@
+from wikimetrics.api import ReplicationLagService
+
+
+class NeverLaggingReplicationLagServiceStub(ReplicationLagService):
+    """ReplicationLagService stub without replication lag"""
+    def is_any_lagged(self):
+        return False

-- 
To view, visit https://gerrit.wikimedia.org/r/155004
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I84629cfad3ff3395e386b8542e0466fa2d2b6a00
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: QChris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to