jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332492?usp=email )
Change subject: tests: Fix repeatable chunked upload test
......................................................................
tests: Fix repeatable chunked upload test
Select a fixture whose SHA-1 differs from the target file's current revision.
This lets MediaWiki publish a new version and removes the expected failure.
Live chunked upload coverage is retained.
Bug: T367320
Change-Id: Idc0d28af6b5e6baeec588518573629e729a660a3
---
M tests/upload_tests.py
1 file changed, 20 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/upload_tests.py b/tests/upload_tests.py
index 76e0553..58bec4b 100755
--- a/tests/upload_tests.py
+++ b/tests/upload_tests.py
@@ -290,13 +290,28 @@
comment='pywikibot test',
ignore_warnings=True)
- @unittest.expectedFailure # T367320
def test_png_chunked(self) -> None:
- """Test uploading a png in two chunks using Site.upload."""
+ """Test uploading a png in chunks using Site.upload."""
page = pywikibot.FilePage(self.site, 'MP_sounds-pwb-chunked.png')
- self.site.upload(page, source_filename=self.sounds_png,
- comment='pywikibot test',
- ignore_warnings=True, chunk_size=1024)
+ current_sha1 = None
+ with suppress(pywikibot.exceptions.PageRelatedError):
+ self.site.loadimageinfo(page)
+ current_sha1 = page.latest_file_info.sha1
+
+ # MediaWiki rejects publishing an exact copy of the current revision,
+ # even when upload warnings are ignored. Alternate between two test
+ # images so repeated test runs still exercise a successful upload.
+ sounds_sha1 = compute_file_hash(self.sounds_png)
+ source_filename = (self.arrow_png
+ if current_sha1 == sounds_sha1
+ else self.sounds_png)
+ source_sha1 = compute_file_hash(source_filename)
+
+ self.assertNotEqual(current_sha1, source_sha1)
+ self.assertTrue(
+ self.site.upload(page, source_filename=source_filename,
+ comment='pywikibot test',
+ ignore_warnings=True, chunk_size=1024))
def _init_upload(self, chunk_size) -> None:
"""Do an initial upload causing an abort because of warnings."""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332492?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: Idc0d28af6b5e6baeec588518573629e729a660a3
Gerrit-Change-Number: 1332492
Gerrit-PatchSet: 1
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]