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

Change subject: data_ingestion: Fix csvdir option parsing
......................................................................

data_ingestion: Fix csvdir option parsing

partition() excludes the separator from the option name. Match the csvdir 
option without the colon.

This accepts the documented directory argument instead of reporting it as both 
missing and unknown.

Change-Id: I63356c4ac8753d509e741536418bb1ed1786bb93
---
M scripts/data_ingestion.py
M tests/data_ingestion_tests.py
2 files changed, 33 insertions(+), 1 deletion(-)

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




diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 63951f9..0355fb6 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -294,7 +294,7 @@
     local_args = gen_factory.handle_args(local_args)
     for arg in local_args:
         opt, _, value = arg.partition(':')
-        if opt == '-csvdir:':
+        if opt == '-csvdir':
             csv_dir = value
         else:
             unknown.append(arg)
diff --git a/tests/data_ingestion_tests.py b/tests/data_ingestion_tests.py
index 07523d8..8df215d 100755
--- a/tests/data_ingestion_tests.py
+++ b/tests/data_ingestion_tests.py
@@ -8,6 +8,7 @@
 from __future__ import annotations

 import unittest
+from unittest.mock import MagicMock, patch

 from scripts import data_ingestion
 from tests import join_data_path, join_images_path
@@ -130,5 +131,36 @@
                 '-page:User:John_Vandenberg/data_ingestion_test_template')


+class TestDataIngestionMain(TestCase):
+
+    """Test :func:`data_ingestion.main`."""
+
+    net = False
+
+    def test_csvdir_option(self) -> None:
+        """Test the -csvdir option is accepted."""
+        generator_factory = MagicMock()
+        generator_factory.handle_args.return_value = [
+            '-csvdir:tests/data']
+        generator_factory.getCombinedGenerator.return_value = object()
+
+        with (
+            patch.object(data_ingestion.pywikibot, 'handle_args',
+                         side_effect=lambda args: args),
+            patch.object(data_ingestion.pagegenerators, 'GeneratorFactory',
+                         return_value=generator_factory),
+            patch.object(data_ingestion.pywikibot.bot, 'suggest_help',
+                         return_value=True) as suggest_help,
+        ):
+            data_ingestion.main('-csvdir:tests/data', '-page:Config')
+
+        generator_factory.handle_args.assert_called_once_with(
+            ('-csvdir:tests/data', '-page:Config'))
+        suggest_help.assert_called_once_with(
+            missing_parameters=None,
+            missing_generator=False,
+            unknown_parameters=[])
+
+
 if __name__ == '__main__':
     unittest.main()

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