|
1 | 1 | import time |
2 | 2 |
|
3 | | -from labelbox import DataRow, ExportTask, StreamType |
| 3 | +from labelbox import DataRow, ExportTask, StreamType, Task, TaskStatus |
4 | 4 |
|
5 | 5 |
|
6 | 6 | class TestExportDataRow: |
@@ -135,3 +135,33 @@ def test_cancel_export_task( |
135 | 135 | # Verify the task was cancelled |
136 | 136 | cancelled_task = client.get_task_by_id(export_task.uid) |
137 | 137 | assert cancelled_task.status in ["CANCELING", "CANCELED"] |
| 138 | + |
| 139 | + def test_task_filter(self, client, data_row, wait_for_data_row_processing): |
| 140 | + organization = client.get_organization() |
| 141 | + user = client.get_user() |
| 142 | + |
| 143 | + export_task = DataRow.export( |
| 144 | + client=client, |
| 145 | + data_rows=[data_row], |
| 146 | + task_name="TestExportDataRow:test_task_filter", |
| 147 | + ) |
| 148 | + |
| 149 | + # Check if task is listed "in progress" in organization's tasks |
| 150 | + org_tasks_in_progress = organization.tasks( |
| 151 | + where=Task.status_type == TaskStatus.In_Progress |
| 152 | + ) |
| 153 | + retrieved_task_in_progress = next( |
| 154 | + (t for t in org_tasks_in_progress if t.uid == export_task.uid), "" |
| 155 | + ) |
| 156 | + assert getattr(retrieved_task_in_progress, "uid", "") == export_task.uid |
| 157 | + |
| 158 | + export_task.wait_till_done() |
| 159 | + |
| 160 | + # Check if task is listed "complete" in user's created tasks |
| 161 | + user_tasks_complete = user.created_tasks( |
| 162 | + where=Task.status_type == TaskStatus.Complete |
| 163 | + ) |
| 164 | + retrieved_task_complete = next( |
| 165 | + (t for t in user_tasks_complete if t.uid == export_task.uid), "" |
| 166 | + ) |
| 167 | + assert getattr(retrieved_task_complete, "uid", "") == export_task.uid |
0 commit comments