From 5812b6bdb7e4ba240c23526c63db197d36983603 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:35:29 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Ad?= =?UTF-8?q?d=20error=20test=20for=20parse=5Fcommand=5Farguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds comprehensive unit tests for the `parse_command_arguments` function in `src/enapter/cli/http/api/command_arguments.py`. 🎯 **What:** The testing gap addressed was the lack of validation for the JSON decoding error path. 📊 **Coverage:** The new tests cover: - Passing `None` (returns empty dict) - Passing valid JSON (returns parsed dict) - Passing invalid JSON (raises `argparse.ArgumentTypeError`) ✨ **Result:** Improved reliability and code coverage for CLI argument parsing. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com> --- tests/unit/test_cli/__init__.py | 0 tests/unit/test_cli/test_http/__init__.py | 0 tests/unit/test_cli/test_http/test_api/__init__.py | 0 .../test_http/test_api/test_command_arguments.py | 14 ++++++++++++++ 4 files changed, 14 insertions(+) create mode 100644 tests/unit/test_cli/__init__.py create mode 100644 tests/unit/test_cli/test_http/__init__.py create mode 100644 tests/unit/test_cli/test_http/test_api/__init__.py create mode 100644 tests/unit/test_cli/test_http/test_api/test_command_arguments.py diff --git a/tests/unit/test_cli/__init__.py b/tests/unit/test_cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_cli/test_http/__init__.py b/tests/unit/test_cli/test_http/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_cli/test_http/test_api/__init__.py b/tests/unit/test_cli/test_http/test_api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_cli/test_http/test_api/test_command_arguments.py b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py new file mode 100644 index 0000000..ab1baa6 --- /dev/null +++ b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py @@ -0,0 +1,14 @@ +import argparse +import pytest +from enapter.cli.http.api.command_arguments import parse_command_arguments + +def test_parse_command_arguments_none(): + assert parse_command_arguments(None) == {} + +def test_parse_command_arguments_valid_json(): + assert parse_command_arguments('{"foo": "bar", "baz": 1}') == {"foo": "bar", "baz": 1} + +def test_parse_command_arguments_invalid_json(): + with pytest.raises(argparse.ArgumentTypeError) as excinfo: + parse_command_arguments('invalid json') + assert "Decode JSON:" in str(excinfo.value) From 2e3fd3d1dc61f9010764492356ac1f7df29f265c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:39:31 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Ad?= =?UTF-8?q?d=20error=20test=20for=20parse=5Fcommand=5Farguments=20(v2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This version includes proper formatting to satisfy the `black` linter, which caused a CI failure in the previous submission. 🎯 **What:** The testing gap addressed was the lack of validation for the JSON decoding error path. 📊 **Coverage:** The new tests cover: - Passing `None` (returns empty dict) - Passing valid JSON (returns parsed dict) - Passing invalid JSON (raises `argparse.ArgumentTypeError`) ✨ **Result:** Improved reliability and code coverage for CLI argument parsing, now with lint-passing code. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com> --- .../test_http/test_api/test_command_arguments.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_cli/test_http/test_api/test_command_arguments.py b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py index ab1baa6..b92652e 100644 --- a/tests/unit/test_cli/test_http/test_api/test_command_arguments.py +++ b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py @@ -1,14 +1,22 @@ import argparse + import pytest + from enapter.cli.http.api.command_arguments import parse_command_arguments + def test_parse_command_arguments_none(): assert parse_command_arguments(None) == {} + def test_parse_command_arguments_valid_json(): - assert parse_command_arguments('{"foo": "bar", "baz": 1}') == {"foo": "bar", "baz": 1} + assert parse_command_arguments('{"foo": "bar", "baz": 1}') == { + "foo": "bar", + "baz": 1, + } + def test_parse_command_arguments_invalid_json(): with pytest.raises(argparse.ArgumentTypeError) as excinfo: - parse_command_arguments('invalid json') + parse_command_arguments("invalid json") assert "Decode JSON:" in str(excinfo.value) From 0fd9012be7a6006f0f0c10adc781d3ac9da81791 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:40:09 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Re?= =?UTF-8?q?factor=20imports=20in=20command=5Farguments=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the test file to import the `command_arguments` module instead of the `parse_command_arguments` function directly, following the project's coding conventions as requested in the PR review. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com> --- .../test_cli/test_http/test_api/test_command_arguments.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_cli/test_http/test_api/test_command_arguments.py b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py index b92652e..cc18b9f 100644 --- a/tests/unit/test_cli/test_http/test_api/test_command_arguments.py +++ b/tests/unit/test_cli/test_http/test_api/test_command_arguments.py @@ -2,15 +2,15 @@ import pytest -from enapter.cli.http.api.command_arguments import parse_command_arguments +from enapter.cli.http.api import command_arguments def test_parse_command_arguments_none(): - assert parse_command_arguments(None) == {} + assert command_arguments.parse_command_arguments(None) == {} def test_parse_command_arguments_valid_json(): - assert parse_command_arguments('{"foo": "bar", "baz": 1}') == { + assert command_arguments.parse_command_arguments('{"foo": "bar", "baz": 1}') == { "foo": "bar", "baz": 1, } @@ -18,5 +18,5 @@ def test_parse_command_arguments_valid_json(): def test_parse_command_arguments_invalid_json(): with pytest.raises(argparse.ArgumentTypeError) as excinfo: - parse_command_arguments("invalid json") + command_arguments.parse_command_arguments("invalid json") assert "Decode JSON:" in str(excinfo.value)