mirror of
https://github.com/Significant-Gravitas/Auto-GPT.git
synced 2025-01-08 11:57:32 +08:00
added smoke test
This commit is contained in:
parent
ca5a52f48a
commit
dc4094b264
5
.gitignore
vendored
5
.gitignore
vendored
@ -151,4 +151,7 @@ dmypy.json
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
llama-*
|
||||
vicuna-*
|
||||
vicuna-*
|
||||
|
||||
# mac
|
||||
.DS_Store
|
||||
|
@ -1,17 +0,0 @@
|
||||
For now there aren't many tests.
|
||||
So just run:
|
||||
|
||||
```
|
||||
python tests/unit/json_tests.py
|
||||
python tests/integration/memory_tests.py
|
||||
```
|
||||
|
||||
paid test:
|
||||
```
|
||||
python tests/integration/test_commands.py
|
||||
```
|
||||
This test costs 0.004$ per run with GPT-3.5. We will setup a pipeline in github action to allow people to run these tests for free.
|
||||
|
||||
The pipeline will be be triggered for now.
|
||||
|
||||
TODO: when we setup pytest, replace lines above by: pytest commands
|
@ -1,18 +1,9 @@
|
||||
import contextlib
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
import platform
|
||||
|
||||
# Import necessary modules for testing, file operations, and handling system paths.
|
||||
|
||||
root_path = Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.append(str(root_path / 'scripts'))
|
||||
from file_operations import read_file
|
||||
from file_operations import delete_file
|
||||
from autogpt.file_operations import delete_file, read_file
|
||||
|
||||
env_vars = {
|
||||
'MEMORY_BACKEND': 'no_memory',
|
||||
@ -28,18 +19,15 @@ class TestCommands(unittest.TestCase):
|
||||
|
||||
# Read the current ai_settings.yaml file and store its content.
|
||||
ai_settings = None
|
||||
with contextlib.suppress(Exception):
|
||||
if os.path.exists('ai_settings.yaml'):
|
||||
with open('ai_settings.yaml', 'r') as f:
|
||||
ai_settings = f.read()
|
||||
os.remove('ai_settings.yaml')
|
||||
|
||||
try:
|
||||
with contextlib.suppress(Exception):
|
||||
if os.path.exists('hello_world.txt'):
|
||||
# Clean up any existing 'hello_world.txt' file before testing.
|
||||
delete_file('hello_world.txt')
|
||||
|
||||
# Remove ai_settings.yaml file to avoid continuing from the previous session.
|
||||
os.remove('ai_settings.yaml')
|
||||
|
||||
# Prepare input data for the test.
|
||||
input_data = '''write_file-GPT
|
||||
an AI designed to use the write_file command to write 'Hello World' into a file named "hello_world.txt" and then use the task_complete command to complete the task.
|
||||
@ -49,8 +37,7 @@ Do not use any other commands.
|
||||
|
||||
y -5
|
||||
EOF'''
|
||||
script_path = root_path / 'scripts' / 'main.py'
|
||||
command = f'{sys.executable} {script_path}'
|
||||
command = f'{sys.executable} -m autogpt'
|
||||
|
||||
# Execute the script with the input data.
|
||||
process = subprocess.Popen(command, stdin=subprocess.PIPE, shell=True, env={**os.environ, **env_vars})
|
@ -1,16 +1,6 @@
|
||||
import unittest
|
||||
<<<<<<< HEAD
|
||||
|
||||
from autogpt.json_parser import fix_and_parse_json
|
||||
=======
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Probably a better way:
|
||||
sys.path.append(str(Path(__file__).resolve().parent.parent.parent / 'scripts'))
|
||||
from json_parser import fix_and_parse_json
|
||||
>>>>>>> 27e0703d (Update sys.path to use pathlib in json_tests.py)
|
||||
|
||||
|
||||
class TestParseJson(unittest.TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user