Skip to content

Commit 2e3fd3d

Browse files
🧪 [testing improvement] Add error test for parse_command_arguments (v2)
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>
1 parent 5812b6b commit 2e3fd3d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import argparse
2+
23
import pytest
4+
35
from enapter.cli.http.api.command_arguments import parse_command_arguments
46

7+
58
def test_parse_command_arguments_none():
69
assert parse_command_arguments(None) == {}
710

11+
812
def test_parse_command_arguments_valid_json():
9-
assert parse_command_arguments('{"foo": "bar", "baz": 1}') == {"foo": "bar", "baz": 1}
13+
assert parse_command_arguments('{"foo": "bar", "baz": 1}') == {
14+
"foo": "bar",
15+
"baz": 1,
16+
}
17+
1018

1119
def test_parse_command_arguments_invalid_json():
1220
with pytest.raises(argparse.ArgumentTypeError) as excinfo:
13-
parse_command_arguments('invalid json')
21+
parse_command_arguments("invalid json")
1422
assert "Decode JSON:" in str(excinfo.value)

0 commit comments

Comments
 (0)