Skip to content

Commit 4e14276

Browse files
authored
Merge pull request #36 from Enapter/add-error-test-for-parse-command-arguments-8490786769286108830
🧪 Add error test for parse_command_arguments
2 parents 58fcb37 + 0fd9012 commit 4e14276

4 files changed

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

0 commit comments

Comments
 (0)