mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-20 15:38:09 +02:00
update ser&deser unittest
This commit is contained in:
parent
311e48b604
commit
e52957026b
28 changed files with 27 additions and 35 deletions
|
|
@ -28,5 +28,5 @@ async def test_action_deserialize():
|
|||
new_action = Action(**serialized_data)
|
||||
|
||||
assert new_action.name == ""
|
||||
assert new_action.llm == LLM()
|
||||
assert isinstance(new_action.llm, type(LLM()))
|
||||
assert len(await new_action._aask("who are you")) > 0
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from metagpt.schema import Message
|
|||
from metagpt.utils.common import any_to_str
|
||||
from tests.metagpt.serialize_deserialize.test_serdeser_base import (
|
||||
ActionOK,
|
||||
ActionRaise,
|
||||
RoleC,
|
||||
serdeser_path,
|
||||
)
|
||||
|
|
@ -55,9 +56,9 @@ def test_environment_serdeser():
|
|||
assert len(new_env.roles) == 1
|
||||
|
||||
assert list(new_env.roles.values())[0].states == list(environment.roles.values())[0].states
|
||||
assert list(new_env.roles.values())[0].actions == list(environment.roles.values())[0].actions
|
||||
assert isinstance(list(environment.roles.values())[0].actions[0], ActionOK)
|
||||
assert type(list(new_env.roles.values())[0].actions[0]) == ActionOK
|
||||
assert type(list(new_env.roles.values())[0].actions[1]) == ActionRaise
|
||||
|
||||
|
||||
def test_environment_serdeser_v2():
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import WriteCode
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.schema import CodingContext, Document
|
||||
|
||||
|
||||
|
|
@ -28,5 +27,4 @@ async def test_write_code_deserialize():
|
|||
new_action = WriteCode(**serialized_data)
|
||||
|
||||
assert new_action.name == "WriteCode"
|
||||
assert new_action.llm == LLM()
|
||||
await action.run()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import WriteCodeReview
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.schema import CodingContext, Document
|
||||
|
||||
|
||||
|
|
@ -28,5 +27,4 @@ def div(a: int, b: int = 0):
|
|||
new_action = WriteCodeReview(**serialized_data)
|
||||
|
||||
assert new_action.name == "WriteCodeReview"
|
||||
assert new_action.llm == LLM()
|
||||
await new_action.run()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import WriteDesign, WriteTasks
|
||||
from metagpt.llm import LLM
|
||||
|
||||
|
||||
def test_write_design_serialize():
|
||||
|
|
@ -28,7 +27,6 @@ async def test_write_design_deserialize():
|
|||
serialized_data = action.model_dump()
|
||||
new_action = WriteDesign(**serialized_data)
|
||||
assert new_action.name == ""
|
||||
assert new_action.llm == LLM()
|
||||
await new_action.run(with_messages="write a cli snake game")
|
||||
|
||||
|
||||
|
|
@ -38,5 +36,4 @@ async def test_write_task_deserialize():
|
|||
serialized_data = action.model_dump()
|
||||
new_action = WriteTasks(**serialized_data)
|
||||
assert new_action.name == "CreateTasks"
|
||||
assert new_action.llm == LLM()
|
||||
await new_action.run(with_messages="write a cli snake game")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import WritePRD
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.schema import Message
|
||||
|
||||
|
||||
|
|
@ -23,6 +22,5 @@ async def test_action_deserialize():
|
|||
serialized_data = action.model_dump()
|
||||
new_action = WritePRD(**serialized_data)
|
||||
assert new_action.name == ""
|
||||
assert new_action.llm == LLM()
|
||||
action_output = await new_action.run(with_messages=Message(content="write a cli snake game"))
|
||||
assert len(action_output.content) > 0
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
@Desc : the unittest of serialize
|
||||
"""
|
||||
|
||||
from typing import List, Tuple
|
||||
from typing import List
|
||||
|
||||
from metagpt.actions import WritePRD
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
|
|
@ -27,7 +27,7 @@ def test_actionoutout_schema_to_mapping():
|
|||
"properties": {"field": {"title": "field", "type": "array", "items": {"type": "string"}}},
|
||||
}
|
||||
mapping = actionoutout_schema_to_mapping(schema)
|
||||
assert mapping["field"] == (List[str], ...)
|
||||
assert mapping["field"] == (list[str], ...)
|
||||
|
||||
schema = {
|
||||
"title": "test",
|
||||
|
|
@ -46,7 +46,7 @@ def test_actionoutout_schema_to_mapping():
|
|||
},
|
||||
}
|
||||
mapping = actionoutout_schema_to_mapping(schema)
|
||||
assert mapping["field"] == (List[Tuple[str, str]], ...)
|
||||
assert mapping["field"] == (list[list[str]], ...)
|
||||
|
||||
assert True, True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue