Skip to content

Commit 5812b6b

Browse files
πŸ§ͺ [testing improvement] Add error test for parse_command_arguments
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>
1 parent 58fcb37 commit 5812b6b

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

β€Žtests/unit/test_cli/__init__.pyβ€Ž

Whitespace-only changes.

β€Žtests/unit/test_cli/test_http/__init__.pyβ€Ž

Whitespace-only changes.

β€Žtests/unit/test_cli/test_http/test_api/__init__.pyβ€Ž

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import argparse
2+
import pytest
3+
from enapter.cli.http.api.command_arguments import parse_command_arguments
4+
5+
def test_parse_command_arguments_none():
6+
assert parse_command_arguments(None) == {}
7+
8+
def test_parse_command_arguments_valid_json():
9+
assert parse_command_arguments('{"foo": "bar", "baz": 1}') == {"foo": "bar", "baz": 1}
10+
11+
def test_parse_command_arguments_invalid_json():
12+
with pytest.raises(argparse.ArgumentTypeError) as excinfo:
13+
parse_command_arguments('invalid json')
14+
assert "Decode JSON:" in str(excinfo.value)

0 commit comments

Comments
Β (0)