forked from danmohad/khod-kaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_integration.py
53 lines (39 loc) · 1.62 KB
/
test_integration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import pytest
import subprocess
from Agent import Agent
from khod_kaar import khod_kaar
class MockArgs:
"""Class to mock the argparser"""
def __init__(self, model_, output_dir_, temperature_, autopilot_, objective_):
self.model = model_
self.output_dir = output_dir_
self.temperature = temperature_
self.autopilot = autopilot_
self.objective = objective_
@pytest.fixture
def simple_args():
"""Fixture to mock simple arguments to create a program that writes 'Hello, World!'."""
args = ['gpt-4',
'./output/',
0.0,
True,
"to write, test and execute a simple Python program that writes 'Hello, World!'."
]
return MockArgs(*args)
def test_integration(simple_args):
"""Integration test for khod-kaar using simple_args.
khod-kaar must execute without errors, and the generated program must print 'Hello, World!'."""
khod_kaar(Agent(simple_args))
# TODO figure out why in GitHub CI, khod-kaar always creates the program inside the
# repo's directory, but when run locally, it behaves correctly and builds out of source.
# Add the below lines back when this is fixed.
# sp = subprocess.run(['python', '../hello_world_project/hello_world.py'],
# check=True, capture_output=True, text=True)
# assert sp.stdout.strip() == 'Hello, World!'
# TODO add this back in when GitHub CI issue is fixed
# @pytest.fixture
# def cleanup(autouse=True):
# """Fixture to clean up filesystem after integration test."""
# yield
# os.rmdir('../hello_world_project')