You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently main.py, our command line program, is only tested using some options in github actions. We should test all of the options
Acceptance criteria
important command line options are tested. We can exclude some options like --plot
Ideas
ChatGPT thinks we can mock some things with pytest. See if something like this works
from acom_music_box import parse_arguments, main, setup_logging
# Test parse_arguments to ensure it handles different arguments correctly
def test_parse_arguments_example(monkeypatch):
test_args = ['music_box', '--example', 'example_name']
monkeypatch.setattr('sys.argv', test_args)
args = parse_arguments()
assert args.example == 'example_name'
assert args.config is None # Ensure --config is ignored when --example is provided
def test_parse_arguments_config(monkeypatch):
test_args = ['music_box', '--config', 'path/to/config.json']
monkeypatch.setattr('sys.argv', test_args)
args = parse_arguments()
assert args.config == 'path/to/config.json'
assert args.example is None
# Mock sys.exit to prevent it from halting the test suite
def test_main_example(monkeypatch):
test_args = ['music_box', '--example', 'example_name']
monkeypatch.setattr('sys.argv', test_args)
with pytest.raises(SystemExit): # Catch the exit to prevent test from stopping
with mock.patch('acom_music_box.MusicBox') as MockMusicBox:
mock_box = MockMusicBox.return_value
mock_box.readConditionsFromJson.return_value = None
mock_box.create_solver.return_value = None
mock_box.solve.return_value = "test_output"
main() # Call the main function
mock_box.readConditionsFromJson.assert_called_once_with('example_name') # Verify behavior
# Test logging setup
def test_setup_logging(mock):
with mock.patch('logging.basicConfig') as mock_basic_config:
setup_logging(verbosity=2, color_output=True)
mock_basic_config.assert_called_once() # Check if logging was properly configured
The text was updated successfully, but these errors were encountered:
Currently
main.py
, our command line program, is only tested using some options in github actions. We should test all of the optionsAcceptance criteria
--plot
Ideas
The text was updated successfully, but these errors were encountered: