jenkins-bot has submitted this change and it was merged.

Change subject: [IMPROV] logentry tests: Also test other versions
......................................................................


[IMPROV] logentry tests: Also test other versions

Currently it only tests on the German Wikipedia but future API changes might
break it so testing it on the test Wikipedia might help find them sooner. It
also tests on an older wiki now which uses the old format.

Change-Id: Ibd8201087639043f9f4903729a0d69ecf4b1106c
---
M tests/aspects.py
M tests/logentry_tests.py
2 files changed, 40 insertions(+), 9 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/aspects.py b/tests/aspects.py
index f96d9f0..73c89ca 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -641,6 +641,7 @@
 
             def wrapped_method(self):
                 sitedata = self.sites[key]
+                self.site_key = key
                 self.family = sitedata['family']
                 self.code = sitedata['code']
                 self.site = sitedata['site']
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index 5c750e5..f6a1611 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -14,6 +14,7 @@
 
 import pywikibot
 from pywikibot.logentries import LogEntryFactory
+from pywikibot.tools import MediaWikiVersion
 
 from tests.aspects import (
     unittest, MetaTestCaseClass, TestCase, DeprecationTestCase
@@ -26,13 +27,38 @@
 
 class TestLogentriesBase(TestCase):
 
-    """Base class for log entry tests."""
+    """
+    Base class for log entry tests.
 
-    family = 'wikipedia'
-    code = 'de'
+    It uses the German Wikipedia for a current representation of the log 
entries
+    and the test Wikipedia for the future representation. It also tests on a
+    wiki with MW 1.19 or older to check that it can still read the older 
format.
+    It currently uses lyricwiki which as of this commit uses 1.19.24.
+    """
+
+    sites = {
+        'tewp': {
+            'family': 'wikipedia',
+            'code': 'test'
+        },
+        'dewp': {
+            'family': 'wikipedia',
+            'code': 'de'
+        },
+        'old': {
+            'family': 'lyricwiki',
+            'code': 'en'
+        }
+    }
 
     def _get_logentry(self, logtype):
         """Retrieve a single log entry."""
+        if self.site_key == 'old':
+            # This is an assertion as the tests don't make sense with newer
+            # MW versions and otherwise it might not be visible that the test
+            # isn't run on an older wiki.
+            self.assertLess(MediaWikiVersion(self.site.version()),
+                            MediaWikiVersion('1.20'))
         return next(iter(self.site.logevents(logtype=logtype, total=1)))
 
 
@@ -44,10 +70,14 @@
         """Create the new class."""
         def test_method(logtype):
 
-            def test_logevent(self):
+            def test_logevent(self, key):
                 """Test a single logtype entry."""
                 logentry = self._get_logentry(logtype)
                 self.assertEqual(logtype, logentry._expectedType)
+                if key == 'old':
+                    self.assertNotIn('params', logentry.data)
+                else:
+                    self.assertNotIn(logentry.type(), logentry.data)
                 self.assertIsInstance(logentry.action(), unicode)
                 self.assertIsInstance(logentry.comment(), unicode)
                 self.assertIsInstance(logentry.logid(), int)
@@ -83,7 +113,7 @@
 
     """Test LogEntry properties specific to their action."""
 
-    def test_BlockEntry(self):
+    def test_BlockEntry(self, key):
         """Test BlockEntry methods."""
         logentry = self._get_logentry('block')
         if logentry.action() == 'block':
@@ -92,13 +122,13 @@
             self.assertIsInstance(logentry.expiry(), pywikibot.Timestamp)
             self.assertIsInstance(logentry.duration(), datetime.timedelta)
 
-    def test_RightsEntry(self):
+    def test_RightsEntry(self, key):
         """Test RightsEntry methods."""
         logentry = self._get_logentry('rights')
         self.assertIsInstance(logentry.oldgroups, list)
         self.assertIsInstance(logentry.newgroups, list)
 
-    def test_MoveEntry(self):
+    def test_MoveEntry(self, key):
         """Test MoveEntry methods."""
         logentry = self._get_logentry('move')
         self.assertIsInstance(logentry.target_ns, pywikibot.site.Namespace)
@@ -108,7 +138,7 @@
         self.assertIsInstance(logentry.target_page, pywikibot.Page)
         self.assertIsInstance(logentry.suppressedredirect(), bool)
 
-    def test_PatrolEntry(self):
+    def test_PatrolEntry(self, key):
         """Test PatrolEntry methods."""
         logentry = self._get_logentry('patrol')
         self.assertIsInstance(logentry.current_id, int)
@@ -120,7 +150,7 @@
 
     """Test cases for deprecated logentry methods."""
 
-    def test_MoveEntry(self):
+    def test_MoveEntry(self, key):
         """Test deprecated MoveEntry methods."""
         logentry = self._get_logentry('move')
         self.assertIsInstance(logentry.new_ns(), int)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibd8201087639043f9f4903729a0d69ecf4b1106c
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to