mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-14 15:25:17 +02:00
modified
This commit is contained in:
parent
04f4a353ad
commit
74217a1df3
5 changed files with 54 additions and 106 deletions
|
|
@ -31,7 +31,7 @@ async def test_write_test():
|
|||
code_to_test=code,
|
||||
test_file_name="test_food.py",
|
||||
source_file_path="/some/dummy/path/cli_snake_game/cli_snake_game/food.py",
|
||||
workspace="/some/dummy/path/cli_snake_game"
|
||||
workspace="/some/dummy/path/cli_snake_game",
|
||||
)
|
||||
logger.info(test_code)
|
||||
|
||||
|
|
@ -40,3 +40,18 @@ async def test_write_test():
|
|||
assert "from cli_snake_game.food import Food" in test_code
|
||||
assert "class TestFood(unittest.TestCase)" in test_code
|
||||
assert "def test_generate" in test_code
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_write_code_invalid_code(mocker):
|
||||
# Mock the _aask method to return an invalid code string
|
||||
mocker.patch.object(WriteTest, "_aask", return_value="Invalid Code String")
|
||||
|
||||
# Create an instance of WriteTest
|
||||
write_test = WriteTest()
|
||||
|
||||
# Call the write_code method
|
||||
code = await write_test.write_code("Some prompt:")
|
||||
|
||||
# Assert that the returned code is the same as the invalid code string
|
||||
assert code == "Invalid Code String"
|
||||
|
|
|
|||
|
|
@ -70,99 +70,3 @@ def test_parse_triple_single_quote():
|
|||
|
||||
parsed_data = decoder.decode(input_data)
|
||||
assert parsed_data["a"] == "b"
|
||||
|
||||
|
||||
# def test_parse_complex():
|
||||
# # Create a custom JSON decoder
|
||||
# decoder = CustomDecoder(strict=False)
|
||||
# # Your provided input with single-quoted strings and line breaks
|
||||
# input_data = '''{
|
||||
# "Required Python third-party packages": [
|
||||
# "flask==1.1.2",
|
||||
# "bcrypt==3.2.0"
|
||||
# ],
|
||||
# "Required Other language third-party packages": [
|
||||
# "No third-party packages are required."
|
||||
# ],
|
||||
# "Full API spec": """
|
||||
# openapi: 3.0.0
|
||||
#
|
||||
# description: A JSON object representing the game state.
|
||||
#
|
||||
# paths:
|
||||
# /game:
|
||||
# get:
|
||||
# summary: Get the current game state.
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The current game state.
|
||||
#
|
||||
# /game/{direction}:
|
||||
# post:
|
||||
# summary: Move the snake in the specified direction.
|
||||
# parameters:
|
||||
# - name: direction
|
||||
# in: path
|
||||
# description: The direction to move the snake (one of UP, DOWN, LEFT, or RIGHT).
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The updated game state.
|
||||
#
|
||||
# /game/{food}:
|
||||
# get:
|
||||
# summary: Get the current food position.
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The current food position.
|
||||
#
|
||||
# /game/{snake}:
|
||||
# get:
|
||||
# summary: Get the current snake position.
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The current snake position.
|
||||
#
|
||||
# /game/{snake}/{direction}:
|
||||
# post:
|
||||
# summary: Set the snake direction.
|
||||
# parameters:
|
||||
# - name: direction
|
||||
# in: path
|
||||
# description: The direction to move the snake (one of UP, DOWN, LEFT, or RIGHT).
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The updated game state.
|
||||
#
|
||||
# /game/end:
|
||||
# post:
|
||||
# summary: End the game.
|
||||
# responses:
|
||||
# '200':
|
||||
# description: The final game state.
|
||||
# "
|
||||
# ],
|
||||
# "Logic Analysis": [
|
||||
# ["game.py","Contains the game logic and snake movement."],
|
||||
# ["snake.py","Contains the snake class and methods."],
|
||||
# ["game_objects.py","Contains the game objects and their properties."],
|
||||
# ["game_logic.py","Contains the game logic and rules."],
|
||||
# ["ui.py","Contains the user interface and display logic."]
|
||||
# ],
|
||||
# "Task list": [
|
||||
# "game.py",
|
||||
# "snake.py",
|
||||
# "game_objects.py",
|
||||
# "game_logic.py",
|
||||
# "ui.py"
|
||||
# ],
|
||||
# "Shared Knowledge": """
|
||||
# The game state is represented by a JSON object.
|
||||
# The snake movement is based on the direction parameter.
|
||||
# The game ends when the snake collides with the wall or eats the food.
|
||||
# """,
|
||||
# "Anything UNCLEAR": "The requirement is clear to me."
|
||||
# }
|
||||
# '''
|
||||
# # Parse the JSON using the custom decoder
|
||||
#
|
||||
# parsed_data = decoder.decode(input_data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue