|
1 | 1 | from typing import Any
|
2 | 2 |
|
3 |
| -from annofabapi.util.task_history import find_rejected_task_history_indices |
| 3 | +from annofabapi.util.task_history import find_rejected_task_history_indices, get_task_creation_datetime |
4 | 4 |
|
5 | 5 |
|
6 | 6 | def test__find_rejected_task_history_indices():
|
@@ -184,3 +184,85 @@ def test__find_rejected_task_history_indices():
|
184 | 184 | ]
|
185 | 185 | actual = find_rejected_task_history_indices(task_histories)
|
186 | 186 | assert actual == [4, 12]
|
| 187 | + |
| 188 | + |
| 189 | +def test__get_task_creation_datetime__タスク作成直後の状態から算出(): |
| 190 | + task = { |
| 191 | + "project_id": "58a2a621-7d4b-41e7-927b-cdc570c1114a", |
| 192 | + "task_id": "20250327_02", |
| 193 | + "phase": "annotation", |
| 194 | + "phase_stage": 1, |
| 195 | + "status": "not_started", |
| 196 | + "input_data_id_list": ["bbc5faf4-f22f-48ac-9393-b524cb3e0034"], |
| 197 | + "account_id": None, |
| 198 | + "histories_by_phase": [], |
| 199 | + "work_time_span": 0, |
| 200 | + "number_of_rejections": 0, |
| 201 | + "started_datetime": None, |
| 202 | + "updated_datetime": "2025-03-27T11:31:23.513+09:00", |
| 203 | + "operation_updated_datetime": "2025-03-27T11:31:23.513+09:00", |
| 204 | + "sampling": None, |
| 205 | + "metadata": {}, |
| 206 | + } |
| 207 | + task_history_list = [ |
| 208 | + { |
| 209 | + "project_id": "58a2a621-7d4b-41e7-927b-cdc570c1114a", |
| 210 | + "task_id": "20250327_02", |
| 211 | + "task_history_id": "f8e21d05-4726-4706-865c-52a85fd8f2ae", |
| 212 | + "started_datetime": None, |
| 213 | + "ended_datetime": None, |
| 214 | + "accumulated_labor_time_milliseconds": "PT0S", |
| 215 | + "phase": "annotation", |
| 216 | + "phase_stage": 1, |
| 217 | + "account_id": None, |
| 218 | + } |
| 219 | + ] |
| 220 | + |
| 221 | + assert get_task_creation_datetime(task, task_history_list) == "2025-03-27T11:31:23.513+09:00" |
| 222 | + |
| 223 | + |
| 224 | +def test__get_task_creation_datetime__タスクに担当者を割り当てた状態から算出(): |
| 225 | + task = { |
| 226 | + "project_id": "58a2a621-7d4b-41e7-927b-cdc570c1114a", |
| 227 | + "task_id": "20250327_32", |
| 228 | + "phase": "annotation", |
| 229 | + "phase_stage": 1, |
| 230 | + "status": "not_started", |
| 231 | + "input_data_id_list": ["dcd56d5f-77a8-4a78-b191-755e109032fa"], |
| 232 | + "account_id": "00589ed0-dd63-40db-abb2-dfe5e13c8299", |
| 233 | + "histories_by_phase": [{"account_id": "00589ed0-dd63-40db-abb2-dfe5e13c8299", "phase": "annotation", "phase_stage": 1, "worked": False}], |
| 234 | + "work_time_span": 0, |
| 235 | + "number_of_rejections": 0, |
| 236 | + "started_datetime": None, |
| 237 | + "updated_datetime": "2025-03-27T13:07:35.04+09:00", |
| 238 | + "operation_updated_datetime": "2025-03-27T11:31:23.482+09:00", |
| 239 | + "sampling": None, |
| 240 | + "metadata": {}, |
| 241 | + } |
| 242 | + |
| 243 | + task_history_list = [ |
| 244 | + { |
| 245 | + "project_id": "58a2a621-7d4b-41e7-927b-cdc570c1114a", |
| 246 | + "task_id": "20250327_32", |
| 247 | + "task_history_id": "ff451241-2ace-40fa-8a5d-f1d688a6d588", |
| 248 | + "started_datetime": "2025-03-27T11:31:22.91+09:00", |
| 249 | + "ended_datetime": None, |
| 250 | + "accumulated_labor_time_milliseconds": "PT0S", |
| 251 | + "phase": "annotation", |
| 252 | + "phase_stage": 1, |
| 253 | + "account_id": None, |
| 254 | + }, |
| 255 | + { |
| 256 | + "project_id": "58a2a621-7d4b-41e7-927b-cdc570c1114a", |
| 257 | + "task_id": "20250327_32", |
| 258 | + "task_history_id": "c239ce9a-36da-4330-ad09-154705c308a5", |
| 259 | + "started_datetime": "2025-03-27T13:07:35.133+09:00", |
| 260 | + "ended_datetime": None, |
| 261 | + "accumulated_labor_time_milliseconds": "PT0S", |
| 262 | + "phase": "annotation", |
| 263 | + "phase_stage": 1, |
| 264 | + "account_id": "00589ed0-dd63-40db-abb2-dfe5e13c8299", |
| 265 | + }, |
| 266 | + ] |
| 267 | + |
| 268 | + assert get_task_creation_datetime(task, task_history_list) == "2025-03-27T11:31:22.91+09:00" |
0 commit comments