mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-23 16:04:22 +01:00
add decorator to tests
Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
This commit is contained in:
committed by
Reinier van der Leer
parent
996a3b331a
commit
eb5a8a87d8
14
tests/integration/goal_oriented/decorators.py
Normal file
14
tests/integration/goal_oriented/decorators.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
|
||||
def requires_openai_api_key(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
if not os.environ.get('OPENAI_API_KEY'):
|
||||
pytest.skip(
|
||||
"Environment variable 'OPENAI_API_KEY' is not set, skipping the test."
|
||||
)
|
||||
else:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
@@ -13,6 +13,7 @@ from autogpt.memory import get_memory
|
||||
|
||||
# from autogpt.prompt import Prompt
|
||||
from autogpt.workspace import WORKSPACE_PATH
|
||||
from tests.integration.goal_oriented.decorators import requires_openai_api_key
|
||||
from tests.integration.goal_oriented.vcr_helper import before_record_request
|
||||
|
||||
current_file_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -27,8 +28,11 @@ my_vcr = vcr.VCR(
|
||||
CFG = Config()
|
||||
|
||||
|
||||
@requires_openai_api_key
|
||||
@pytest.mark.integration_test
|
||||
def test_write_file() -> None:
|
||||
# Your test code here
|
||||
|
||||
# if file exist
|
||||
file_name = "hello_world.txt"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user