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

Commit

Permalink
Add test_et_jsonizer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TaekyungHeo committed Nov 27, 2023
1 parent 122ff78 commit ddf1a25
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_et_jsonizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
from chakra.et_jsonizer import main
from unittest.mock import patch, mock_open

def test_run_with_valid_input():
test_args = ["et_jsonizer.py", "--input_filename", "valid_input.et", "--output_filename", "output.json"]
with patch('sys.argv', test_args), \
patch('chakra.et_jsonizer.open_file_rd') as mock_open_file_rd, \
patch('builtins.open', mock_open()):
main() # No assertion needed; we're checking if it runs without error

def test_missing_arguments():
with pytest.raises(SystemExit):
with patch('sys.argv', ['et_jsonizer.py']):
main()

def test_missing_file_path():
test_args = ["et_jsonizer.py", "--input_filename", "nonexistent_input.et", "--output_filename", "output.json"]
with patch('sys.argv', test_args):
with pytest.raises(FileNotFoundError):
main()

0 comments on commit ddf1a25

Please sign in to comment.