|
4 | 4 | # tz_jst = datetime.timezone(datetime.timedelta(hours=9))
|
5 | 5 | # assert to_iso8601_extension(d, tz_jst) == "2019-10-08T16:20:08.241+09:00"
|
6 | 6 |
|
7 |
| -from annofabapi.utils import get_task_history_index_skipped_acceptance, get_task_history_index_skipped_inspection |
| 7 | +from annofabapi.models import TaskPhase |
| 8 | +from annofabapi.utils import (get_number_of_rejections, get_task_history_index_skipped_acceptance, |
| 9 | + get_task_history_index_skipped_inspection) |
8 | 10 |
|
9 | 11 |
|
10 | 12 | class TestTaskHistoryUtils:
|
@@ -236,3 +238,111 @@ def test_get_task_history_index_skipped_inspection_検査2回_検査1回目で
|
236 | 238 | actual = get_task_history_index_skipped_inspection(task_history_list)
|
237 | 239 | expected = []
|
238 | 240 | assert all([a == b for a, b in zip(actual, expected)])
|
| 241 | + |
| 242 | + def test_get_number_of_rejections_教師付1回目(self): |
| 243 | + task_history_short_list = [{ |
| 244 | + "account_id": self.ACCOUNT_ID, |
| 245 | + "phase": "annotation", |
| 246 | + "phase_stage": 1, |
| 247 | + "worked": True |
| 248 | + }] |
| 249 | + |
| 250 | + actual = get_number_of_rejections(task_history_short_list, TaskPhase.ACCEPTANCE) |
| 251 | + assert actual == 0 |
| 252 | + |
| 253 | + def test_get_number_of_rejections_受入で1回差戻(self): |
| 254 | + task_history_short_list = [ |
| 255 | + { |
| 256 | + "account_id": self.ACCOUNT_ID, |
| 257 | + 'phase': 'annotation', |
| 258 | + 'phase_stage': 1, |
| 259 | + 'worked': True |
| 260 | + }, |
| 261 | + { |
| 262 | + "account_id": self.ACCOUNT_ID, |
| 263 | + 'phase': 'acceptance', |
| 264 | + 'phase_stage': 1, |
| 265 | + 'worked': True |
| 266 | + }, |
| 267 | + { |
| 268 | + "account_id": self.ACCOUNT_ID, |
| 269 | + 'phase': 'annotation', |
| 270 | + 'phase_stage': 1, |
| 271 | + 'worked': True |
| 272 | + }, |
| 273 | + ] |
| 274 | + |
| 275 | + actual = get_number_of_rejections(task_history_short_list, TaskPhase.ACCEPTANCE) |
| 276 | + assert actual == 1 |
| 277 | + |
| 278 | + def test_get_number_of_rejections_検査で1回差戻(self): |
| 279 | + task_history_short_list = [ |
| 280 | + { |
| 281 | + "account_id": self.ACCOUNT_ID, |
| 282 | + 'phase': 'annotation', |
| 283 | + 'phase_stage': 1, |
| 284 | + 'worked': True |
| 285 | + }, |
| 286 | + { |
| 287 | + "account_id": self.ACCOUNT_ID, |
| 288 | + 'phase': 'inspection', |
| 289 | + 'phase_stage': 1, |
| 290 | + 'worked': True |
| 291 | + }, |
| 292 | + { |
| 293 | + "account_id": self.ACCOUNT_ID, |
| 294 | + 'phase': 'annotation', |
| 295 | + 'phase_stage': 1, |
| 296 | + 'worked': True |
| 297 | + }, |
| 298 | + ] |
| 299 | + |
| 300 | + actual = get_number_of_rejections(task_history_short_list, TaskPhase.INSPECTION) |
| 301 | + assert actual == 1 |
| 302 | + |
| 303 | + def test_get_number_of_rejections_検査と受入で1回差戻(self): |
| 304 | + task_history_short_list = [{ |
| 305 | + "account_id": self.ACCOUNT_ID, |
| 306 | + "phase": "annotation", |
| 307 | + "phase_stage": 1, |
| 308 | + "worked": True |
| 309 | + }, { |
| 310 | + "account_id": self.ACCOUNT_ID, |
| 311 | + "phase": "inspection", |
| 312 | + "phase_stage": 1, |
| 313 | + "worked": True |
| 314 | + }, { |
| 315 | + "account_id": self.ACCOUNT_ID, |
| 316 | + "phase": "annotation", |
| 317 | + "phase_stage": 1, |
| 318 | + "worked": True |
| 319 | + }, { |
| 320 | + "account_id": self.ACCOUNT_ID, |
| 321 | + "phase": "inspection", |
| 322 | + "phase_stage": 1, |
| 323 | + "worked": True |
| 324 | + }, { |
| 325 | + "account_id": self.ACCOUNT_ID, |
| 326 | + "phase": "acceptance", |
| 327 | + "phase_stage": 1, |
| 328 | + "worked": True |
| 329 | + }, { |
| 330 | + "account_id": self.ACCOUNT_ID, |
| 331 | + "phase": "annotation", |
| 332 | + "phase_stage": 1, |
| 333 | + "worked": True |
| 334 | + }, { |
| 335 | + "account_id": "00589ed0-dd63-40db-abb2-dfe5e13c8299", |
| 336 | + "phase": "inspection", |
| 337 | + "phase_stage": 1, |
| 338 | + "worked": True |
| 339 | + }, { |
| 340 | + "account_id": self.ACCOUNT_ID, |
| 341 | + "phase": "acceptance", |
| 342 | + "phase_stage": 1, |
| 343 | + "worked": True |
| 344 | + }] |
| 345 | + actual_inspection = get_number_of_rejections(task_history_short_list, TaskPhase.INSPECTION) |
| 346 | + assert actual_inspection == 1 |
| 347 | + actual_acceptance = get_number_of_rejections(task_history_short_list, TaskPhase.ACCEPTANCE) |
| 348 | + assert actual_acceptance == 1 |
0 commit comments