44
55from plane .client import PlaneClient
66from plane .models .projects import Project
7- from plane .models .query_params import PaginatedQueryParams
7+ from plane .models .query_params import PaginatedQueryParams , WorkItemQueryParams
88from plane .models .work_items import AdvancedSearchWorkItem , CreateWorkItem , UpdateWorkItem
99
1010
@@ -31,16 +31,55 @@ def test_list_work_items_with_params(
3131 assert hasattr (response , "results" )
3232 assert len (response .results ) <= 10
3333
34+ def test_list_work_items_with_pql_filter (
35+ self , client : PlaneClient , workspace_slug : str , project : Project
36+ ) -> None :
37+ """Test listing work items with a PQL filter."""
38+ created_item = None
39+ created_item_2 = None
40+
41+ try :
42+ created_item = client .work_items .create (
43+ workspace_slug ,
44+ project .id ,
45+ CreateWorkItem (
46+ name = "pql-filter-high-priority-item" ,
47+ priority = "high" ,
48+ ),
49+ )
50+
51+ created_item_2 = client .work_items .create (
52+ workspace_slug ,
53+ project .id ,
54+ CreateWorkItem (
55+ name = "pql-filter-low-priority-item" ,
56+ priority = "low" ,
57+ ),
58+ )
59+ params = WorkItemQueryParams (pql = 'priority IN ("high")' )
60+ response = client .work_items .list (workspace_slug , project .id , params = params )
61+ assert response is not None
62+ assert hasattr (response , "results" )
63+ assert isinstance (response .results , list )
64+ assert len (response .results ) > 0
65+ result_ids = [item .id for item in response .results ]
66+
67+ assert created_item .id in result_ids
68+ assert created_item_2 .id not in result_ids
69+ finally :
70+ if created_item is not None :
71+ client .work_items .delete (workspace_slug , project .id , created_item .id )
72+ if created_item_2 is not None :
73+ client .work_items .delete (workspace_slug , project .id , created_item_2 .id )
74+
3475 def test_search_work_items (self , client : PlaneClient , workspace_slug : str ) -> None :
3576 """Test searching work items."""
3677 response = client .work_items .search (workspace_slug , "test" )
3778 assert response is not None
3879 assert hasattr (response , "issues" )
3980 assert isinstance (response .issues , list )
4081
41- def test_advanced_search_work_items (
42- self , client : PlaneClient , workspace_slug : str
43- ) -> None :
82+ def test_advanced_search_work_items (self , client : PlaneClient , workspace_slug : str ) -> None :
4483 """Test advanced search with query only."""
4584 data = AdvancedSearchWorkItem (query = "test" , limit = 10 )
4685 results = client .work_items .advanced_search (workspace_slug , data )
@@ -52,9 +91,7 @@ def test_advanced_search_work_items(
5291 assert item .project_id is not None
5392 assert item .workspace_id is not None
5493
55- def test_advanced_search_with_filters (
56- self , client : PlaneClient , workspace_slug : str
57- ) -> None :
94+ def test_advanced_search_with_filters (self , client : PlaneClient , workspace_slug : str ) -> None :
5895 """Test advanced search with filters."""
5996 data = AdvancedSearchWorkItem (
6097 filters = {
@@ -96,6 +133,7 @@ class TestWorkItemsAPICRUD:
96133 def work_item_data (self ) -> CreateWorkItem :
97134 """Create test work item data."""
98135 import time
136+
99137 return CreateWorkItem (
100138 name = f"Test Work Item { int (time .time ())} " ,
101139 description_html = "<p>Test work item description</p>" ,
@@ -130,7 +168,7 @@ def test_create_work_item(
130168 assert work_item is not None
131169 assert work_item .id is not None
132170 assert work_item .name == work_item_data .name
133-
171+
134172 # Cleanup
135173 try :
136174 client .work_items .delete (workspace_slug , project .id , work_item .id )
@@ -160,14 +198,12 @@ class TestWorkItemsSubResources:
160198 """Test WorkItems sub-resources (comments, links, relations, etc.)."""
161199
162200 @pytest .fixture
163- def work_item (
164- self , client : PlaneClient , workspace_slug : str , project : Project
165- ):
201+ def work_item (self , client : PlaneClient , workspace_slug : str , project : Project ):
166202 """Create a test work item."""
167203 import time
168204
169205 from plane .models .work_items import CreateWorkItem
170-
206+
171207 work_item_data = CreateWorkItem (
172208 name = f"Test Work Item { int (time .time ())} " ,
173209 description_html = "<p>Test work item</p>" ,
@@ -217,4 +253,3 @@ def test_list_attachments(
217253 response = client .work_items .attachments .list (workspace_slug , project .id , work_item .id )
218254 assert response is not None
219255 assert isinstance (response , list )
220-
0 commit comments