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",
"SLIDER",
]
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"
SLIDER = "SLIDER"


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 SLIDER."""

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",
"SLIDER",
]
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",
"SLIDER",
]
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)
- SLIDER: whole number from 0 to 10 (0 is a value; clear a slider with DELETE)
- 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
2 changes: 1 addition & 1 deletion tests/unit/test_customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class TestCustomerPropertyTypesOffline:

BASE = {"name": "tier", "display_name": "Tier"}

@pytest.mark.parametrize("property_type", ["FORMULA", "CASCADING"])
@pytest.mark.parametrize("property_type", ["FORMULA", "CASCADING", "SLIDER"])
def test_a_work_item_only_type_is_refused(self, property_type: str) -> None:
with pytest.raises(ValueError, match="property_type"):
CreateCustomerProperty(**self.BASE, property_type=property_type)
Expand Down
47 changes: 47 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,53 @@ def test_a_cascading_property_parses(self) -> None:

assert prop.property_type == PropertyType.CASCADING

def test_a_slider_property_parses(self) -> None:
"""Same failure as CASCADING: one SLIDER property broke listing the workspace's.
Its server-owned settings have no display_format, so they read as a plain dict."""
prop = WorkItemProperty.model_validate(
{
"id": "p",
"property_type": "SLIDER",
"display_name": "Confidence",
"settings": {"min": 0, "max": 10},
}
)

assert prop.property_type == PropertyType.SLIDER
assert prop.settings == {"min": 0, "max": 10}

def test_a_slider_property_is_created_without_settings(self) -> None:
"""The server assigns a slider's settings and refuses any sent on create."""
body = CreateWorkItemProperty(display_name="Confidence", property_type=PropertyType.SLIDER)

dumped = body.model_dump(exclude_none=True)
assert dumped["property_type"] == "SLIDER"
assert "settings" not in dumped

@pytest.mark.parametrize("value", [0, 7, 10])
def test_a_slider_value_stays_an_int(self, value: int) -> None:
"""Plane returns a slider value as an int; the union had no int, so 7 read back as
7.0 -- and 0, a real slider value, must not read as False."""
detail = WorkItemPropertyValueDetail.model_validate(
{"id": "v", "property_id": "p", "issue_id": "w", "value": value}
)

assert detail.value == value
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_a_slider_zero_is_sent(self) -> None:
"""0 sets a slider; it is not dropped as empty."""
body = CreateWorkItemPropertyValue(value=0)

assert body.model_dump(exclude_none=True) == {"value": 0}

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
28 changes: 28 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,31 @@ 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_slider_property_parses(model: type[WorkItemProperty | WorkItemTypeProperty]) -> None:
"""The golden lists SLIDER; without it in the Literal one slider property made
listing a workspace's properties, or a type's, raise ValidationError."""
prop = model.model_validate(
{
"id": "p1",
"display_name": "Confidence",
"property_type": "SLIDER",
"settings": {"min": 0, "max": 10},
}
)

assert prop.property_type == "SLIDER"
assert prop.settings == {"min": 0, "max": 10}


def test_create_a_slider_property_without_settings() -> None:
"""The server assigns a slider's settings and refuses any sent on create."""
body = CreateWorkItemProperty(display_name="Confidence", property_type="SLIDER")

dumped = body.model_dump(exclude_none=True)
assert dumped["property_type"] == "SLIDER"
assert "settings" not in dumped


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