Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plane/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"FILE",
"FORMULA",
"CASCADING",
"RATING",
]
RelationTypeEnum = Literal["ISSUE", "USER", "RELEASE", "RICH_TEXT"]
CycleStatusEnum = Literal["current", "upcoming", "completed", "draft", "incomplete"]
Expand All @@ -80,6 +81,7 @@ class PropertyType(str, Enum):
FILE = "FILE"
FORMULA = "FORMULA"
CASCADING = "CASCADING"
RATING = "RATING"


class RelationType(str, Enum):
Expand All @@ -92,7 +94,7 @@ class RelationType(str, Enum):


class CustomerPropertyType(str, Enum):
"""Customer property types -- the work item set without FORMULA and CASCADING."""
"""Customer property types -- the work item set without FORMULA, CASCADING and RATING."""

TEXT = "TEXT"
DATETIME = "DATETIME"
Expand Down
1 change: 1 addition & 0 deletions plane/models/v2/work_item_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"EMAIL",
"FILE",
"FORMULA",
"RATING",
]
WorkItemPropertyRelationType = Literal["ISSUE", "USER", "RELEASE", "RICH_TEXT"]

Expand Down
1 change: 1 addition & 0 deletions plane/models/v2/work_item_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"EMAIL",
"FILE",
"FORMULA",
"RATING",
]
WorkItemPropertyRelationType = Literal["ISSUE", "USER", "RELEASE", "RICH_TEXT"]

Expand Down
3 changes: 2 additions & 1 deletion plane/models/work_item_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class CreateWorkItemPropertyValue(BaseModel):
- DATETIME: string (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)
- DECIMAL: number (int or float)
- BOOLEAN: boolean (true/false)
- RATING: integer from 1 to 5 (clear a rating with DELETE, not 0)
- OPTION/RELATION (single): string (UUID)
- OPTION/RELATION (multi, when is_multi=True): list of strings (UUIDs) or single string
- RELATION with relation_type=RICH_TEXT: RichTextValue
Expand Down Expand Up @@ -323,7 +324,7 @@ class WorkItemPropertyValueDetail(BaseModel):
id: str = Field(..., description="Unique identifier for this property value")
property_id: str = Field(..., description="ID of the property")
issue_id: str = Field(..., description="ID of the work item")
value: str | bool | float | None = Field(
value: str | bool | int | float | None = Field(
..., description="The actual value, formatted according to property type"
)
value_type: str | None = Field(None, description="Type of the value")
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test_work_item_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,30 @@ def test_a_cascading_property_parses(self) -> None:

assert prop.property_type == PropertyType.CASCADING

def test_a_rating_property_parses(self) -> None:
"""Same failure as CASCADING: one RATING property broke listing the workspace's."""
prop = WorkItemProperty.model_validate(
{"id": "p", "property_type": "RATING", "display_name": "Impact"}
)

assert prop.property_type == PropertyType.RATING

def test_a_rating_value_stays_an_int(self) -> None:
"""Plane returns a rating as an int; the union had no int, so 4 read back as 4.0."""
detail = WorkItemPropertyValueDetail.model_validate(
{"id": "v", "property_id": "p", "issue_id": "w", "value": 4}
)

assert detail.value == 4
assert type(detail.value) is int

def test_a_decimal_value_stays_a_float(self) -> None:
detail = WorkItemPropertyValueDetail.model_validate(
{"id": "v", "property_id": "p", "issue_id": "w", "value": 4.5}
)

assert type(detail.value) is float

def test_rich_text_is_a_relation_type_not_a_property_type(self) -> None:
assert "RICH_TEXT" in {member.value for member in RelationType}
assert "RICH_TEXT" not in {member.value for member in PropertyType}
Expand Down
17 changes: 17 additions & 0 deletions tests/v2/test_work_item_properties_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
CreateWorkItemPropertyOption,
UpdateWorkItemProperty,
UpdateWorkItemPropertyOption,
WorkItemProperty,
)
from plane.models.v2.work_item_types import WorkItemProperty as WorkItemTypeProperty

PROJECT_BASE = "https://api.example.com/api/v2/workspaces/acme/projects/ENG/work-item-properties"
WORKSPACE_BASE = "https://api.example.com/api/v2/workspaces/acme/work-item-properties"
Expand Down Expand Up @@ -482,5 +484,20 @@ def test_workspace_options_crud(workspace_options: WorkspaceWorkItemPropertyOpti
assert responses.calls[3].request.url == f"{WORKSPACE_BASE}/p1/options/o1/"


@pytest.mark.parametrize("model", [WorkItemProperty, WorkItemTypeProperty])
def test_a_rating_property_parses(model: type[WorkItemProperty | WorkItemTypeProperty]) -> None:
"""The golden lists RATING; without it in the Literal one rating property made
listing a workspace's properties, or a type's, raise ValidationError."""
prop = model.model_validate({"id": "p1", "display_name": "Impact", "property_type": "RATING"})

assert prop.property_type == "RATING"


def test_create_a_rating_property() -> None:
body = CreateWorkItemProperty(display_name="Impact", property_type="RATING")

assert body.model_dump(exclude_none=True)["property_type"] == "RATING"


# -- Navigation: a fetched property reaches its options/contexts -- see
# tests/v2/test_loaded_work_item_properties.py.
Loading