|
|
|
|
|
import pytest |
|
|
|
from gpt_engineer.benchmark.bench_config import ( |
|
AppsConfig, |
|
BenchConfig, |
|
GptmeConfig, |
|
MbppConfig, |
|
) |
|
|
|
|
|
class TestBenchConfig: |
|
|
|
def test_default_values(self): |
|
config = BenchConfig() |
|
assert isinstance(config.apps, AppsConfig) |
|
assert isinstance(config.mbpp, MbppConfig) |
|
assert isinstance(config.gptme, GptmeConfig) |
|
assert config.apps.active is True |
|
assert config.apps.test_start_index == 0 |
|
assert config.apps.test_end_index == 1 |
|
assert config.apps.train_start_index == 0 |
|
assert config.apps.train_end_index == 0 |
|
assert config.mbpp.active is True |
|
assert config.mbpp.test_len == 1 |
|
assert config.mbpp.train_len == 0 |
|
assert config.gptme.active is True |
|
|
|
|
|
def test_specific_values(self): |
|
config = BenchConfig( |
|
apps=AppsConfig( |
|
active=False, |
|
test_start_index=1, |
|
test_end_index=2, |
|
train_start_index=3, |
|
train_end_index=4, |
|
), |
|
mbpp=MbppConfig(active=False, test_len=5, train_len=6), |
|
gptme=GptmeConfig(active=False), |
|
) |
|
assert isinstance(config.apps, AppsConfig) |
|
assert isinstance(config.mbpp, MbppConfig) |
|
assert isinstance(config.gptme, GptmeConfig) |
|
assert config.apps.active is False |
|
assert config.apps.test_start_index == 1 |
|
assert config.apps.test_end_index == 2 |
|
assert config.apps.train_start_index == 3 |
|
assert config.apps.train_end_index == 4 |
|
assert config.mbpp.active is False |
|
assert config.mbpp.test_len == 5 |
|
assert config.mbpp.train_len == 6 |
|
assert config.gptme.active is False |
|
|
|
|
|
def test_from_dict_valid_dict(self): |
|
config_dict = { |
|
"apps": { |
|
"active": False, |
|
"test_start_index": 1, |
|
"test_end_index": 2, |
|
"train_start_index": 3, |
|
"train_end_index": 4, |
|
}, |
|
"mbpp": {"active": False, "test_len": 5, "train_len": 6}, |
|
"gptme": {"active": False}, |
|
} |
|
config = BenchConfig.from_dict(config_dict) |
|
assert isinstance(config.apps, AppsConfig) |
|
assert isinstance(config.mbpp, MbppConfig) |
|
assert isinstance(config.gptme, GptmeConfig) |
|
assert config.apps.active is False |
|
assert config.apps.test_start_index == 1 |
|
assert config.apps.test_end_index == 2 |
|
assert config.apps.train_start_index == 3 |
|
assert config.apps.train_end_index == 4 |
|
assert config.mbpp.active is False |
|
assert config.mbpp.test_len == 5 |
|
assert config.mbpp.train_len == 6 |
|
assert config.gptme.active is False |
|
|
|
|
|
def test_from_toml_invalid_path(self): |
|
config_file = "invalid_config.toml" |
|
with pytest.raises(Exception): |
|
BenchConfig.from_toml(config_file) |
|
|