jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337333?usp=email )

Change subject: tests: Correct file revision visibility assertions
......................................................................

tests: Correct file revision visibility assertions

The file revision test hid user and content fields but then asserted
that their hidden flags were absent. Corrected those assertions and
removed the expected-failure marker.

Checked the fixture revisions directly so missing entries cannot bypass
assertions. Registered restoration with addCleanup so it also runs when
the test fails, and reused the test case's configured site.

Offline checks reproduced the original assertion failure and verified
the corrected checks and cleanup. Live write verification requires the
test wiki account with revision-deletion rights.

Bug: T367309
Change-Id: Iee69878b6ea785bd5cdae2f4427e305ba853db90
---
M tests/site_tests.py
1 file changed, 14 insertions(+), 19 deletions(-)

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




diff --git a/tests/site_tests.py b/tests/site_tests.py
index 9f0dfa1..fd864e3 100755
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -778,10 +778,9 @@
                         show='content|comment|user',
                         reason='pywikibot unit tests')

-    @unittest.expectedFailure  # T367309
     def test_revdel_file(self) -> None:
         """Test deleting and undeleting file revisions."""
-        site = pywikibot.Site('test')
+        site = self.get_site()

         # Verify state
         site.deleterevs('oldimage', [20210314184415, 20210314184430],
@@ -789,6 +788,11 @@
                         reason='pywikibot unit tests',
                         target='File:T276726.png')

+        self.addCleanup(
+            site.deleterevs, 'oldimage', [20210314184415, 20210314184430],
+            show='content|comment|user', reason='pywikibot unit tests',
+            target='File:T276726.png')
+
         # Single revision
         site.deleterevs('oldimage', '20210314184415', hide='user', show='',
                         reason='pywikibot unit tests',
@@ -799,9 +803,7 @@

         fp1 = pywikibot.FilePage(site, 'File:T276726.png')
         site.loadimageinfo(fp1, history=True)
-        for v in fp1._file_revisions.values():
-            if v['timestamp'] == ts1:
-                self.assertHasAttr(v, 'userhidden')
+        self.assertHasAttr(fp1._file_revisions[ts1], 'userhidden')

         # Multiple revisions
         site.deleterevs('oldimage', '20210314184415|20210314184430',
@@ -810,9 +812,8 @@

         fp2 = pywikibot.FilePage(site, 'File:T276726.png')
         site.loadimageinfo(fp2, history=True)
-        for v in fp2._file_revisions.values():
-            if v['timestamp'] in (ts1, ts2):
-                self.assertHasAttr(v, 'commenthidden')
+        for ts in (ts1, ts2):
+            self.assertHasAttr(fp2._file_revisions[ts], 'commenthidden')

         # Concurrently show and hide
         site.deleterevs('oldimage', ['20210314184415', '20210314184430'],
@@ -822,17 +823,11 @@

         fp3 = pywikibot.FilePage(site, 'File:T276726.png')
         site.loadimageinfo(fp3, history=True)
-        for v in fp3._file_revisions.values():
-            if v['timestamp'] in (ts1, ts2):
-                self.assertNotHasAttr(v, 'commenthidden')
-                self.assertNotHasAttr(v, 'userhidden')
-                self.assertNotHasAttr(v, 'filehidden')
-
-        # Cleanup
-        site.deleterevs('oldimage', [20210314184415, 20210314184430],
-                        show='content|comment|user',
-                        reason='pywikibot unit tests',
-                        target='File:T276726.png')
+        for ts in (ts1, ts2):
+            info = fp3._file_revisions[ts]
+            self.assertNotHasAttr(info, 'commenthidden')
+            self.assertHasAttr(info, 'userhidden')
+            self.assertHasAttr(info, 'filehidden')

     def test_delete_oldimage(self) -> None:
         """Test deleting and undeleting specific versions of files."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337333?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iee69878b6ea785bd5cdae2f4427e305ba853db90
Gerrit-Change-Number: 1337333
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to