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

Change subject: imagetransfer: Parse chunk size as integer
......................................................................

imagetransfer: Parse chunk size as integer

Convert the command-line value before passing it to UploadRobot. This
prevents string/integer comparisons during chunked uploads.

Change-Id: Ie7f47eeceec6fa0791807a3cb6342fac45260a5e
---
M scripts/imagetransfer.py
A tests/imagetransfer_tests.py
2 files changed, 43 insertions(+), 1 deletion(-)

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




diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index c7962b8..81feaa4 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -390,7 +390,7 @@
         elif opt == '-tosite':
             options['target'] = value
         elif opt == '-chunk_size':
-            options['chunk_size'] = value
+            options['chunk_size'] = int(value)
         else:
             generator_factory.handle_arg(arg)

diff --git a/tests/imagetransfer_tests.py b/tests/imagetransfer_tests.py
new file mode 100755
index 0000000..861cf4b
--- /dev/null
+++ b/tests/imagetransfer_tests.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+#
+# (C) Pywikibot team, 2026
+#
+# Distributed under the terms of the MIT license.
+#
+"""Tests for the imagetransfer script."""
+from __future__ import annotations
+
+import unittest
+from unittest.mock import Mock, patch
+
+from scripts.imagetransfer import main
+from tests.aspects import TestCase
+
+
+class TestImageTransferMain(TestCase):
+
+    """Test cases for the imagetransfer script."""
+
+    net = False
+
+    def test_chunk_size(self) -> None:
+        """Test that the chunk size is passed as an integer."""
+        generator = object()
+        factory = Mock()
+        factory.getCombinedGenerator.return_value = generator
+
+        with patch('scripts.imagetransfer.pywikibot.handle_args',
+                   return_value=['-chunk_size:1024']), \
+             patch('scripts.imagetransfer.pagegenerators.GeneratorFactory',
+                   return_value=factory), \
+             patch('scripts.imagetransfer.ImageTransferBot') as bot_class:
+            main()
+
+        bot_class.assert_called_once_with(generator=generator,
+                                          chunk_size=1024)
+        bot_class.return_value.run.assert_called_once_with()
+
+
+if __name__ == '__main__':
+    unittest.main()

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1335026?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: Ie7f47eeceec6fa0791807a3cb6342fac45260a5e
Gerrit-Change-Number: 1335026
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