Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 6238674

Browse files
committed
Add test_et_jsonizer.py
1 parent b207374 commit 6238674

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_et_jsonizer.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
from chakra.et_jsonizer import main
3+
from unittest.mock import patch, mock_open
4+
5+
def test_run_with_valid_input():
6+
test_args = ["et_jsonizer.py", "--input_filename", "valid_input.et", "--output_filename", "output.json"]
7+
with patch('sys.argv', test_args), \
8+
patch('chakra.et_jsonizer.open_file_rd') as mock_open_file_rd, \
9+
patch('builtins.open', mock_open()):
10+
main() # No assertion needed; we're checking if it runs without error
11+
12+
def test_missing_arguments():
13+
with pytest.raises(SystemExit):
14+
with patch('sys.argv', ['et_jsonizer.py']):
15+
main()
16+
17+
def test_missing_file_path():
18+
test_args = ["et_jsonizer.py", "--input_filename", "nonexistent_input.et", "--output_filename", "output.json"]
19+
with patch('sys.argv', test_args):
20+
with pytest.raises(FileNotFoundError):
21+
main()

0 commit comments

Comments
 (0)