File size: 1,444 Bytes
3b33bb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""
Data models for the Unittestcasegenerator Environment.

The UnitTestCaseGenerator environment is a simple test environment that echoes back messages.
"""
from typing import Optional
from openenv.core.env_server.types import Action, Observation
from pydantic import Field


class UnittestcasegeneratorAction(Action):
    """Action for the Unittestcasegenerator environment - just a message to echo."""

    test_code: str = Field(..., description="Java JUnit test code")


class UnittestcasegeneratorObservation(Observation):
    """Observation from the Unittestcasegenerator environment - the echoed message."""

    source_code: str = Field(..., description="Java source code to test")
    task_hint: str = Field(..., description="Instructions for writing tests")
    passed: int = Field(default=0, description="Tests passed")
    failed: int = Field(default=0, description="Tests failed")
    total: int = Field(default=0, description="Total tests run")
    error: Optional[str] = Field(default=None, description="Error message if any")
    reward: float = Field(default=0.0, description="Score 0.0 to 1.0")
    done: bool = Field(default=False, description="Episode finished?")
    metadata: Optional[dict] = Field(default=None)