3
from autogpt.models.base_open_ai_plugin import BaseOpenAIPlugin
6
class DummyPlugin(BaseOpenAIPlugin):
7
"""A dummy plugin for testing purposes."""
12
"""A dummy plugin for testing purposes."""
13
manifests_specs_clients = {
15
"name_for_model": "Dummy",
16
"schema_version": "1.0",
17
"description_for_model": "A dummy plugin for testing purposes",
22
return DummyPlugin(manifests_specs_clients)
25
def test_dummy_plugin_inheritance(dummy_plugin):
26
"""Test that the DummyPlugin class inherits from the BaseOpenAIPlugin class."""
27
assert isinstance(dummy_plugin, BaseOpenAIPlugin)
30
def test_dummy_plugin_name(dummy_plugin):
31
"""Test that the DummyPlugin class has the correct name."""
32
assert dummy_plugin._name == "Dummy"
35
def test_dummy_plugin_version(dummy_plugin):
36
"""Test that the DummyPlugin class has the correct version."""
37
assert dummy_plugin._version == "1.0"
40
def test_dummy_plugin_description(dummy_plugin):
41
"""Test that the DummyPlugin class has the correct description."""
42
assert dummy_plugin._description == "A dummy plugin for testing purposes"
45
def test_dummy_plugin_default_methods(dummy_plugin):
46
"""Test that the DummyPlugin class has the correct default methods."""
47
assert not dummy_plugin.can_handle_on_response()
48
assert not dummy_plugin.can_handle_post_prompt()
49
assert not dummy_plugin.can_handle_on_planning()
50
assert not dummy_plugin.can_handle_post_planning()
51
assert not dummy_plugin.can_handle_pre_instruction()
52
assert not dummy_plugin.can_handle_on_instruction()
53
assert not dummy_plugin.can_handle_post_instruction()
54
assert not dummy_plugin.can_handle_pre_command()
55
assert not dummy_plugin.can_handle_post_command()
56
assert not dummy_plugin.can_handle_chat_completion(None, None, None, None)
57
assert not dummy_plugin.can_handle_text_embedding(None)
59
assert dummy_plugin.on_response("hello") == "hello"
60
assert dummy_plugin.post_prompt(None) is None
61
assert dummy_plugin.on_planning(None, None) is None
62
assert dummy_plugin.post_planning("world") == "world"
63
pre_instruction = dummy_plugin.pre_instruction(
64
[{"role": "system", "content": "Beep, bop, boop"}]
66
assert isinstance(pre_instruction, list)
67
assert len(pre_instruction) == 1
68
assert pre_instruction[0]["role"] == "system"
69
assert pre_instruction[0]["content"] == "Beep, bop, boop"
70
assert dummy_plugin.on_instruction(None) is None
71
assert dummy_plugin.post_instruction("I'm a robot") == "I'm a robot"
72
pre_command = dummy_plugin.pre_command("evolve", {"continuously": True})
73
assert isinstance(pre_command, tuple)
74
assert len(pre_command) == 2
75
assert pre_command[0] == "evolve"
76
assert pre_command[1]["continuously"] is True
77
post_command = dummy_plugin.post_command("evolve", "upgraded successfully!")
78
assert isinstance(post_command, str)
79
assert post_command == "upgraded successfully!"
80
assert dummy_plugin.handle_chat_completion(None, None, None, None) is None
81
assert dummy_plugin.handle_text_embedding(None) is None