Skip to content

Commit 6bef0f2

Browse files
fix: test cases
1 parent ba04ab2 commit 6bef0f2

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

plane/models/query_params.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class BaseQueryParams(BaseModel):
2828
None,
2929
description="Field to order results by. Prefix with '-' for descending order",
3030
)
31-
pql: str | None = Field(None, description="Field to apply PQL filters")
3231

3332

3433
class PaginatedQueryParams(BaseQueryParams):
@@ -63,6 +62,8 @@ class WorkItemQueryParams(PaginatedQueryParams):
6362

6463
model_config = ConfigDict(extra="ignore", populate_by_name=True)
6564

65+
pql: str | None = Field(None, description="PQL filters ")
66+
6667

6768
class RetrieveQueryParams(BaseQueryParams):
6869
"""Query parameters for retrieve endpoints."""

tests/unit/test_work_items.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ def test_list_work_items_with_pql_filter(
3535
self, client: PlaneClient, workspace_slug: str, project: Project
3636
) -> None:
3737
"""Test listing work items with a PQL filter."""
38+
created_item = client.work_items.create(
39+
workspace_slug,
40+
project.id,
41+
CreateWorkItem(
42+
name="pql-filter-high-priority-item",
43+
priority="high",
44+
),
45+
)
3846
params = WorkItemQueryParams(pql='priority IN ("high")')
3947
response = client.work_items.list(workspace_slug, project.id, params=params)
4048
assert response is not None
4149
assert hasattr(response, "results")
4250
assert isinstance(response.results, list)
43-
for item in response.results:
44-
assert item.priority == "high"
51+
assert len(response.results) > 0
52+
result_ids = [item.id for item in response.results]
53+
assert created_item.id in result_ids
4554

4655
def test_search_work_items(self, client: PlaneClient, workspace_slug: str) -> None:
4756
"""Test searching work items."""
@@ -50,9 +59,7 @@ def test_search_work_items(self, client: PlaneClient, workspace_slug: str) -> No
5059
assert hasattr(response, "issues")
5160
assert isinstance(response.issues, list)
5261

53-
def test_advanced_search_work_items(
54-
self, client: PlaneClient, workspace_slug: str
55-
) -> None:
62+
def test_advanced_search_work_items(self, client: PlaneClient, workspace_slug: str) -> None:
5663
"""Test advanced search with query only."""
5764
data = AdvancedSearchWorkItem(query="test", limit=10)
5865
results = client.work_items.advanced_search(workspace_slug, data)
@@ -64,9 +71,7 @@ def test_advanced_search_work_items(
6471
assert item.project_id is not None
6572
assert item.workspace_id is not None
6673

67-
def test_advanced_search_with_filters(
68-
self, client: PlaneClient, workspace_slug: str
69-
) -> None:
74+
def test_advanced_search_with_filters(self, client: PlaneClient, workspace_slug: str) -> None:
7075
"""Test advanced search with filters."""
7176
data = AdvancedSearchWorkItem(
7277
filters={
@@ -108,6 +113,7 @@ class TestWorkItemsAPICRUD:
108113
def work_item_data(self) -> CreateWorkItem:
109114
"""Create test work item data."""
110115
import time
116+
111117
return CreateWorkItem(
112118
name=f"Test Work Item {int(time.time())}",
113119
description_html="<p>Test work item description</p>",
@@ -142,7 +148,7 @@ def test_create_work_item(
142148
assert work_item is not None
143149
assert work_item.id is not None
144150
assert work_item.name == work_item_data.name
145-
151+
146152
# Cleanup
147153
try:
148154
client.work_items.delete(workspace_slug, project.id, work_item.id)
@@ -172,14 +178,12 @@ class TestWorkItemsSubResources:
172178
"""Test WorkItems sub-resources (comments, links, relations, etc.)."""
173179

174180
@pytest.fixture
175-
def work_item(
176-
self, client: PlaneClient, workspace_slug: str, project: Project
177-
):
181+
def work_item(self, client: PlaneClient, workspace_slug: str, project: Project):
178182
"""Create a test work item."""
179183
import time
180184

181185
from plane.models.work_items import CreateWorkItem
182-
186+
183187
work_item_data = CreateWorkItem(
184188
name=f"Test Work Item {int(time.time())}",
185189
description_html="<p>Test work item</p>",
@@ -229,4 +233,3 @@ def test_list_attachments(
229233
response = client.work_items.attachments.list(workspace_slug, project.id, work_item.id)
230234
assert response is not None
231235
assert isinstance(response, list)
232-

0 commit comments

Comments
 (0)