mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-16 12:34:20 +01:00
Revert "Revert "Merge branch 'master' into stable""
This reverts commit 999990b614.
This commit is contained in:
79
tests/unit/models/test_base_open_api_plugin.py
Normal file
79
tests/unit/models/test_base_open_api_plugin.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
from autogpt.models.base_open_ai_plugin import (
|
||||
BaseOpenAIPlugin,
|
||||
Message,
|
||||
PromptGenerator,
|
||||
)
|
||||
|
||||
|
||||
class DummyPlugin(BaseOpenAIPlugin):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_plugin():
|
||||
manifests_specs_clients = {
|
||||
"manifest": {
|
||||
"name_for_model": "Dummy",
|
||||
"schema_version": "1.0",
|
||||
"description_for_model": "A dummy plugin for testing purposes",
|
||||
},
|
||||
"client": None,
|
||||
"openapi_spec": None,
|
||||
}
|
||||
return DummyPlugin(manifests_specs_clients)
|
||||
|
||||
|
||||
def test_dummy_plugin_inheritance(dummy_plugin):
|
||||
assert isinstance(dummy_plugin, BaseOpenAIPlugin)
|
||||
|
||||
|
||||
def test_dummy_plugin_name(dummy_plugin):
|
||||
assert dummy_plugin._name == "Dummy"
|
||||
|
||||
|
||||
def test_dummy_plugin_version(dummy_plugin):
|
||||
assert dummy_plugin._version == "1.0"
|
||||
|
||||
|
||||
def test_dummy_plugin_description(dummy_plugin):
|
||||
assert dummy_plugin._description == "A dummy plugin for testing purposes"
|
||||
|
||||
|
||||
def test_dummy_plugin_default_methods(dummy_plugin):
|
||||
assert not dummy_plugin.can_handle_on_response()
|
||||
assert not dummy_plugin.can_handle_post_prompt()
|
||||
assert not dummy_plugin.can_handle_on_planning()
|
||||
assert not dummy_plugin.can_handle_post_planning()
|
||||
assert not dummy_plugin.can_handle_pre_instruction()
|
||||
assert not dummy_plugin.can_handle_on_instruction()
|
||||
assert not dummy_plugin.can_handle_post_instruction()
|
||||
assert not dummy_plugin.can_handle_pre_command()
|
||||
assert not dummy_plugin.can_handle_post_command()
|
||||
assert not dummy_plugin.can_handle_chat_completion(None, None, None, None)
|
||||
|
||||
assert dummy_plugin.on_response("hello") == "hello"
|
||||
assert dummy_plugin.post_prompt(None) is None
|
||||
assert dummy_plugin.on_planning(None, None) is None
|
||||
assert dummy_plugin.post_planning("world") == "world"
|
||||
pre_instruction = dummy_plugin.pre_instruction(
|
||||
[{"role": "system", "content": "Beep, bop, boop"}]
|
||||
)
|
||||
assert isinstance(pre_instruction, list)
|
||||
assert len(pre_instruction) == 1
|
||||
assert pre_instruction[0]["role"] == "system"
|
||||
assert pre_instruction[0]["content"] == "Beep, bop, boop"
|
||||
assert dummy_plugin.on_instruction(None) is None
|
||||
assert dummy_plugin.post_instruction("I'm a robot") == "I'm a robot"
|
||||
pre_command = dummy_plugin.pre_command("evolve", {"continuously": True})
|
||||
assert isinstance(pre_command, tuple)
|
||||
assert len(pre_command) == 2
|
||||
assert pre_command[0] == "evolve"
|
||||
assert pre_command[1]["continuously"] == True
|
||||
post_command = dummy_plugin.post_command("evolve", "upgraded successfully!")
|
||||
assert isinstance(post_command, str)
|
||||
assert post_command == "upgraded successfully!"
|
||||
assert dummy_plugin.handle_chat_completion(None, None, None, None) is None
|
||||
Reference in New Issue
Block a user