Skip to content

Commit

Permalink
Update tests to match the changes on the config parser
Browse files Browse the repository at this point in the history
  • Loading branch information
verovaleros committed Feb 13, 2024
1 parent b1d2758 commit d682bf2
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions tests/test_hermeneisGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,41 @@
from os import path
from unittest.mock import patch

sys.path.append( path.dirname(path.dirname( path.abspath(__file__) ) ))
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from hermeneisGPT import load_and_parse_config


def test_load_and_parse_config_success(tmp_path):
directory = tmp_path / "sub"
directory.mkdir()
path = directory / "config.yaml"
path.write_text("""
personality:
type: test_type
prompt: test_prompt
system: system_prompt
user: user_prompt
model: test_model
temperature: 0.5
max_tokens: 100
temperature: "0.5"
max_tokens: "100"
log: output.log
""", encoding='utf-8')

# Patch 'logging.Logger.info' and 'logging.Logger.error'
with patch.object(logging.Logger, 'info') as mock_info, \
# Patch 'logging.Logger.debug' and 'logging.Logger.error'
with patch.object(logging.Logger, 'debug') as mock_debug, \
patch.object(logging.Logger, 'error') as mock_error:
config = load_and_parse_config(str(path))

# Check if 'info' was called at least once
mock_info.assert_called()
# Check if 'debug' was called at least once
mock_debug.assert_called()
# Check if 'error' was not called, indicating no errors occurred
mock_error.assert_not_called()
assert config == {
'type': 'test_type',
'prompt': 'test_prompt',
'system': 'system_prompt',
'user': 'user_prompt',
'model': 'test_model',
'temperature': 0.5,
'max_tokens': 100,
'log': 'output.log'
'log': 'output.log',
}


# Example of a failure to load due to file not found or other IO issues
def test_load_and_parse_config_failure(tmp_path):
non_existent_file_path = tmp_path / "does_not_exist.yaml"
Expand All @@ -53,3 +51,4 @@ def test_load_and_parse_config_failure(tmp_path):

# Check if 'error' was called at least once
mock_error.assert_called_once()

0 comments on commit d682bf2

Please sign in to comment.