-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
430cc00
commit 0275b19
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |