mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
refactor: Refactor imports to be compatible with unit tests
This commit is contained in:
0
scripts/__init__.py
Normal file
0
scripts/__init__.py
Normal file
@@ -1,7 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from config import Config
|
from .config import Config
|
||||||
from llm_utils import create_chat_completion
|
from .llm_utils import create_chat_completion
|
||||||
|
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from config import Config
|
from .config import Config
|
||||||
|
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
from llm_utils import create_chat_completion
|
from .llm_utils import create_chat_completion
|
||||||
# This is a magic function that can do anything with no-code. See
|
# This is a magic function that can do anything with no-code. See
|
||||||
# https://github.com/Torantulino/AI-Functions for more info.
|
# https://github.com/Torantulino/AI-Functions for more info.
|
||||||
def call_ai_function(function, args, description, model=None):
|
def call_ai_function(function, args, description, model=None):
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
from typing import Any, Dict, Union
|
from typing import Any, Dict, Union
|
||||||
from call_ai_function import call_ai_function
|
from .call_ai_function import call_ai_function
|
||||||
from config import Config
|
from .config import Config
|
||||||
from json_utils import correct_json
|
from .json_utils import correct_json
|
||||||
|
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
from config import Config
|
from .config import Config
|
||||||
|
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import openai
|
import openai
|
||||||
from config import Config
|
from .config import Config
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
openai.api_key = cfg.openai_api_key
|
openai.api_key = cfg.openai_api_key
|
||||||
|
|||||||
8
tests.py
Normal file
8
tests.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Load all tests from the 'scripts/tests' package
|
||||||
|
suite = unittest.defaultTestLoader.discover('scripts/tests')
|
||||||
|
|
||||||
|
# Run the tests
|
||||||
|
unittest.TextTestRunner().run(suite)
|
||||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
4
tests/context.py
Normal file
4
tests/context.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path.insert(0, os.path.abspath(
|
||||||
|
os.path.join(os.path.dirname(__file__), '..')))
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
# Generated by CodiumAI
|
# Generated by CodiumAI
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import pytest
|
|
||||||
|
|
||||||
from scripts.browse import scrape_text
|
from scripts.browse import scrape_text
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import os
|
|
||||||
import sys
|
from scripts.json_parser import fix_and_parse_json
|
||||||
# Probably a better way:
|
|
||||||
sys.path.append(os.path.abspath('../scripts'))
|
|
||||||
from json_parser import fix_and_parse_json
|
|
||||||
|
|
||||||
class TestParseJson(unittest.TestCase):
|
class TestParseJson(unittest.TestCase):
|
||||||
def test_valid_json(self):
|
def test_valid_json(self):
|
||||||
Reference in New Issue
Block a user