Coverage for tests\test_post_api_projects_modelization.py: 100.00%

143 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-03-22 23:23 +0100

1# -*- coding: utf-8 -*- 

2 

3""" 

4* Name: interactive-clustering-gui/tests/test_post_api_projects_modelization.py 

5* Description: Unittests for `app` module on the `POST /api/projects/{project_id}/modelization` route. 

6* Author: Erwan Schild 

7* Created: 22/02/2022 

8* Licence: CeCILL (https://cecill.info/licences.fr.html) 

9""" 

10 

11from pathlib import Path 

12 

13import pytest 

14 

15from tests.dummies_utils import create_dummy_projects 

16 

17# ============================================================================== 

18# test_ko_not_found 

19# ============================================================================== 

20 

21 

22@pytest.mark.asyncio() 

23async def test_ko_not_found(async_client): 

24 """ 

25 Test the `POST /api/projects/{project_id}/modelization` route with not existing project. 

26 

27 Arguments: 

28 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

29 """ 

30 # Assert HTTP client is created. 

31 assert async_client 

32 

33 # Assert route `POST /api/projects/{project_id}/modelization` works. 

34 response_post = await async_client.post(url="/api/projects/UNKNOWN_PROJECT/modelization") 

35 assert response_post.status_code == 404 

36 assert response_post.json() == { 

37 "detail": "The project with id 'UNKNOWN_PROJECT' doesn't exist.", 

38 } 

39 

40 

41# ============================================================================== 

42# test_ko_bad_state_1 

43# ============================================================================== 

44 

45 

46@pytest.mark.asyncio() 

47async def test_ko_bad_state_1(async_client, tmp_path): 

48 """ 

49 Test the `POST /api/projects/{project_id}/modelization` route with bad state. 

50 

51 Arguments: 

52 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

53 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

54 """ 

55 # Assert HTTP client is created. 

56 assert async_client 

57 

58 # Create dummy projects. 

59 create_dummy_projects( 

60 tmp_path=tmp_path, 

61 list_of_dummy_project_ids=[ 

62 "0b_INITIALIZATION_WITH_PENDING_MODELIZATION", 

63 ], 

64 ) 

65 

66 # Assert route `POST /api/projects/{project_id}/modelization` works. 

67 response_post = await async_client.post( 

68 url="/api/projects/0b_INITIALIZATION_WITH_PENDING_MODELIZATION/modelization" 

69 ) 

70 assert response_post.status_code == 403 

71 assert response_post.json() == { 

72 "detail": "The project with id '0b_INITIALIZATION_WITH_PENDING_MODELIZATION' doesn't allow the preparation of modelization update task during this state (state='INITIALIZATION_WITH_PENDING_MODELIZATION')." 

73 } 

74 

75 # Assert route `GET /api/projects/{project_id}/status` is still the same. 

76 response_get = await async_client.get(url="/api/projects/0b_INITIALIZATION_WITH_PENDING_MODELIZATION/status") 

77 assert response_get.status_code == 200 

78 assert response_get.json()["status"]["iteration_id"] == 0 

79 assert response_get.json()["status"]["state"] == "INITIALIZATION_WITH_PENDING_MODELIZATION" 

80 

81 

82# ============================================================================== 

83# test_ko_bad_state_2 

84# ============================================================================== 

85 

86 

87@pytest.mark.asyncio() 

88async def test_ko_bad_state_2(async_client, tmp_path): 

89 """ 

90 Test the `POST /api/projects/{project_id}/modelization` route with bad state. 

91 

92 Arguments: 

93 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

94 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

95 """ 

96 # Assert HTTP client is created. 

97 assert async_client 

98 

99 # Create dummy projects. 

100 create_dummy_projects( 

101 tmp_path=tmp_path, 

102 list_of_dummy_project_ids=[ 

103 "1b_SAMPLING_PENDING", 

104 ], 

105 ) 

106 

107 # Assert route `POST /api/projects/{project_id}/modelization` works. 

108 response_post = await async_client.post(url="/api/projects/1b_SAMPLING_PENDING/modelization") 

109 assert response_post.status_code == 403 

110 assert response_post.json() == { 

111 "detail": "The project with id '1b_SAMPLING_PENDING' doesn't allow the preparation of modelization update task during this state (state='SAMPLING_PENDING')." 

112 } 

113 

114 # Assert route `GET /api/projects/{project_id}/status` is still the same. 

115 response_get = await async_client.get(url="/api/projects/1b_SAMPLING_PENDING/status") 

116 assert response_get.status_code == 200 

117 assert response_get.json()["status"]["iteration_id"] == 1 

118 assert response_get.json()["status"]["state"] == "SAMPLING_PENDING" 

119 

120 

121# ============================================================================== 

122# test_ko_bad_state_3 

123# ============================================================================== 

124 

125 

126@pytest.mark.asyncio() 

127async def test_ko_bad_state_3(async_client, tmp_path): 

128 """ 

129 Test the `POST /api/projects/{project_id}/modelization` route with bad state. 

130 

131 Arguments: 

132 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

133 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

134 """ 

135 # Assert HTTP client is created. 

136 assert async_client 

137 

138 # Create dummy projects. 

139 create_dummy_projects( 

140 tmp_path=tmp_path, 

141 list_of_dummy_project_ids=[ 

142 "1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS", 

143 ], 

144 ) 

145 

146 # Assert route `POST /api/projects/{project_id}/modelization` works. 

147 response_post = await async_client.post( 

148 url="/api/projects/1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS/modelization" 

149 ) 

150 assert response_post.status_code == 403 

151 assert response_post.json() == { 

152 "detail": "The project with id '1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS' doesn't allow the preparation of modelization update task during this state (state='ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS')." 

153 } 

154 

155 # Assert route `GET /api/projects/{project_id}/status` is still the same. 

156 response_get = await async_client.get( 

157 url="/api/projects/1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS/status" 

158 ) 

159 assert response_get.status_code == 200 

160 assert response_get.json()["status"]["iteration_id"] == 1 

161 assert response_get.json()["status"]["state"] == "ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS" 

162 

163 

164# ============================================================================== 

165# test_ko_bad_state_4 

166# ============================================================================== 

167 

168 

169@pytest.mark.asyncio() 

170async def test_ko_bad_state_4(async_client, tmp_path): 

171 """ 

172 Test the `POST /api/projects/{project_id}/modelization` route with bad state. 

173 

174 Arguments: 

175 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

176 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

177 """ 

178 # Assert HTTP client is created. 

179 assert async_client 

180 

181 # Create dummy projects. 

182 create_dummy_projects( 

183 tmp_path=tmp_path, 

184 list_of_dummy_project_ids=[ 

185 "1o_CLUSTERING_WORKING", 

186 ], 

187 ) 

188 

189 # Assert route `POST /api/projects/{project_id}/modelization` works. 

190 response_post = await async_client.post(url="/api/projects/1o_CLUSTERING_WORKING/modelization") 

191 assert response_post.status_code == 403 

192 assert response_post.json() == { 

193 "detail": "The project with id '1o_CLUSTERING_WORKING' doesn't allow the preparation of modelization update task during this state (state='CLUSTERING_WORKING')." 

194 } 

195 

196 # Assert route `GET /api/projects/{project_id}/status` is still the same. 

197 response_get = await async_client.get(url="/api/projects/1o_CLUSTERING_WORKING/status") 

198 assert response_get.status_code == 200 

199 assert response_get.json()["status"]["iteration_id"] == 1 

200 assert response_get.json()["status"]["state"] == "CLUSTERING_WORKING" 

201 

202 

203# ============================================================================== 

204# test_ok_1_202 

205# ============================================================================== 

206 

207 

208@pytest.mark.asyncio() 

209async def test_ok_1_202(async_client, tmp_path): 

210 """ 

211 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

212 

213 Arguments: 

214 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

215 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

216 """ 

217 # Assert HTTP client is created. 

218 assert async_client 

219 

220 # Create dummy projects. 

221 create_dummy_projects( 

222 tmp_path=tmp_path, 

223 list_of_dummy_project_ids=[ 

224 "0a_INITIALIZATION_WITHOUT_MODELIZATION", 

225 ], 

226 ) 

227 

228 # Assert route `POST /api/projects/{project_id}/modelization` works. 

229 response_post = await async_client.post(url="/api/projects/0a_INITIALIZATION_WITHOUT_MODELIZATION/modelization") 

230 assert response_post.status_code == 202 

231 assert response_post.json() == { 

232 "project_id": "0a_INITIALIZATION_WITHOUT_MODELIZATION", 

233 "detail": "In project with id '0a_INITIALIZATION_WITHOUT_MODELIZATION', the modelization update task has been requested and is waiting for a background task.", 

234 } 

235 

236 # Assert route `GET /api/projects/{project_id}/status` is update. 

237 response_get = await async_client.get(url="/api/projects/0a_INITIALIZATION_WITHOUT_MODELIZATION/status") 

238 assert response_get.status_code == 200 

239 assert response_get.json()["status"]["iteration_id"] == 0 

240 assert response_get.json()["status"]["state"] in { 

241 "INITIALIZATION_WITH_PENDING_MODELIZATION", 

242 "INITIALIZATION_WITH_WORKING_MODELIZATION", 

243 "CLUSTERING_TODO", 

244 } 

245 if response_get.json()["status"]["state"] in { 

246 "INITIALIZATION_WITH_PENDING_MODELIZATION", 

247 "INITIALIZATION_WITH_WORKING_MODELIZATION", 

248 }: # pragma: nocover 

249 assert response_get.json()["status"]["task"] is not None 

250 else: # pragma: nocover 

251 assert response_get.json()["status"]["task"] is None 

252 

253 

254# ============================================================================== 

255# test_ok_2_202 

256# ============================================================================== 

257 

258 

259@pytest.mark.asyncio() 

260async def test_ok_2_202(async_client): 

261 """ 

262 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

263 

264 Arguments: 

265 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

266 """ 

267 # Assert HTTP client is created. 

268 assert async_client 

269 

270 # Import project. 

271 with open(Path(__file__).parent / "dummies" / "archive-1b_SAMPLING_PENDING.zip", "rb") as archive_fileobject: 

272 response_put = await async_client.put( 

273 url="/api/projects", 

274 files={ 

275 "project_archive": ( 

276 "archive-1b_SAMPLING_PENDING.zip", 

277 archive_fileobject, 

278 "application/x-zip-compressed", 

279 ), 

280 }, 

281 ) 

282 assert response_put.status_code == 201 

283 imported_project_id: str = response_put.json()["project_id"] 

284 

285 # Assert route `POST /api/projects/{project_id}/modelization` works. 

286 response_post = await async_client.post(url="/api/projects/" + imported_project_id + "/modelization") 

287 assert response_post.status_code == 202 

288 assert response_post.json() == { 

289 "project_id": imported_project_id, 

290 "detail": ( 

291 "In project with id '" 

292 + imported_project_id 

293 + "', the modelization update task has been requested and is waiting for a background task." 

294 ), 

295 } 

296 

297 # Assert route `GET /api/projects/{project_id}/status` is update. 

298 response_get = await async_client.get(url="/api/projects/" + imported_project_id + "/status") 

299 assert response_get.status_code == 200 

300 assert response_get.json()["status"]["iteration_id"] == 1 

301 assert response_get.json()["status"]["state"] in { 

302 "IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION", 

303 "IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION", 

304 "SAMPLING_TODO", 

305 } 

306 if response_get.json()["status"]["state"] in { 

307 "IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION", 

308 "IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION", 

309 }: # pragma: nocover 

310 assert response_get.json()["status"]["task"] is not None 

311 else: # pragma: nocover 

312 assert response_get.json()["status"]["task"] is None 

313 

314 

315# ============================================================================== 

316# test_ok_3_202 

317# ============================================================================== 

318 

319 

320@pytest.mark.asyncio() 

321async def test_ok_3_202(async_client): 

322 """ 

323 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

324 

325 Arguments: 

326 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

327 """ 

328 # Assert HTTP client is created. 

329 assert async_client 

330 

331 # Import project. 

332 with open( 

333 Path(__file__).parent / "dummies" / "archive-1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS.zip", "rb" 

334 ) as archive_fileobject: 

335 response_put = await async_client.put( 

336 url="/api/projects", 

337 files={ 

338 "project_archive": ( 

339 "archive-1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS.zip", 

340 archive_fileobject, 

341 "application/x-zip-compressed", 

342 ), 

343 }, 

344 ) 

345 assert response_put.status_code == 201 

346 imported_project_id: str = response_put.json()["project_id"] 

347 

348 # Assert route `POST /api/projects/{project_id}/modelization` works. 

349 response_post = await async_client.post(url="/api/projects/" + imported_project_id + "/modelization") 

350 assert response_post.status_code == 202 

351 assert response_post.json() == { 

352 "project_id": imported_project_id, 

353 "detail": ( 

354 "In project with id '" 

355 + imported_project_id 

356 + "', the modelization update task has been requested and is waiting for a background task." 

357 ), 

358 } 

359 

360 # Assert route `GET /api/projects/{project_id}/status` is update. 

361 response_get = await async_client.get(url="/api/projects/" + imported_project_id + "/status") 

362 assert response_get.status_code == 200 

363 assert response_get.json()["status"]["iteration_id"] == 1 

364 assert response_get.json()["status"]["state"] in { 

365 "IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION", 

366 "IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION", 

367 "ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS", 

368 } 

369 if response_get.json()["status"]["state"] in { 

370 "IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION", 

371 "IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION", 

372 }: # pragma: nocover 

373 assert response_get.json()["status"]["task"] is not None 

374 else: # pragma: nocover 

375 assert response_get.json()["status"]["task"] is None 

376 

377 

378# ============================================================================== 

379# test_ok_4_202 

380# ============================================================================== 

381 

382 

383@pytest.mark.asyncio() 

384async def test_ok_4_202(async_client): 

385 """ 

386 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

387 

388 Arguments: 

389 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

390 """ 

391 # Assert HTTP client is created. 

392 assert async_client 

393 

394 # Import project. 

395 with open(Path(__file__).parent / "dummies" / "archive-1o_CLUSTERING_WORKING.zip", "rb") as archive_fileobject: 

396 response_put = await async_client.put( 

397 url="/api/projects", 

398 files={ 

399 "project_archive": ( 

400 "archive-1o_CLUSTERING_WORKING.zip", 

401 archive_fileobject, 

402 "application/x-zip-compressed", 

403 ), 

404 }, 

405 ) 

406 assert response_put.status_code == 201 

407 imported_project_id: str = response_put.json()["project_id"] 

408 

409 # Assert route `POST /api/projects/{project_id}/modelization` works. 

410 response_post = await async_client.post(url="/api/projects/" + imported_project_id + "/modelization") 

411 assert response_post.status_code == 202 

412 assert response_post.json() == { 

413 "project_id": imported_project_id, 

414 "detail": ( 

415 "In project with id '" 

416 + imported_project_id 

417 + "', the modelization update task has been requested and is waiting for a background task." 

418 ), 

419 } 

420 

421 # Assert route `GET /api/projects/{project_id}/status` is update. 

422 response_get = await async_client.get(url="/api/projects/" + imported_project_id + "/status") 

423 assert response_get.status_code == 200 

424 assert response_get.json()["status"]["iteration_id"] == 1 

425 assert response_get.json()["status"]["state"] in { 

426 "IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION", 

427 "IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION", 

428 "CLUSTERING_TODO", 

429 } 

430 if response_get.json()["status"]["state"] in { 

431 "IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION", 

432 "IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION", 

433 }: # pragma: nocover 

434 assert response_get.json()["status"]["task"] is not None 

435 else: # pragma: nocover 

436 assert response_get.json()["status"]["task"] is None 

437 

438 

439# ============================================================================== 

440# test_ok_5_202 

441# ============================================================================== 

442 

443 

444@pytest.mark.asyncio() 

445async def test_ok_5_202(async_client): 

446 """ 

447 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

448 

449 Arguments: 

450 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

451 """ 

452 # Assert HTTP client is created. 

453 assert async_client 

454 

455 # Import project. 

456 with open(Path(__file__).parent / "dummies" / "archive-1p_ITERATION_END.zip", "rb") as archive_fileobject: 

457 response_put = await async_client.put( 

458 url="/api/projects", 

459 files={ 

460 "project_archive": ( 

461 "archive-1p_ITERATION_END.zip", 

462 archive_fileobject, 

463 "application/x-zip-compressed", 

464 ), 

465 }, 

466 ) 

467 assert response_put.status_code == 201 

468 imported_project_id: str = response_put.json()["project_id"] 

469 

470 # Assert route `POST /api/projects/{project_id}/modelization` works. 

471 response_post = await async_client.post(url="/api/projects/" + imported_project_id + "/modelization") 

472 assert response_post.status_code == 202 

473 assert response_post.json() == { 

474 "project_id": imported_project_id, 

475 "detail": ( 

476 "In project with id '" 

477 + imported_project_id 

478 + "', the modelization update task has been requested and is waiting for a background task." 

479 ), 

480 } 

481 

482 # Assert route `GET /api/projects/{project_id}/status` is update. 

483 response_get = await async_client.get(url="/api/projects/" + imported_project_id + "/status") 

484 assert response_get.status_code == 200 

485 assert response_get.json()["status"]["iteration_id"] == 1 

486 assert response_get.json()["status"]["state"] in { 

487 "IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION", 

488 "IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION", 

489 "ITERATION_END", 

490 } 

491 if response_get.json()["status"]["state"] in { 

492 "IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION", 

493 "IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION", 

494 }: # pragma: nocover 

495 assert response_get.json()["status"]["task"] is not None 

496 else: # pragma: nocover 

497 assert response_get.json()["status"]["task"] is None 

498 

499 

500# ============================================================================== 

501# test_ok_6_202 

502# ============================================================================== 

503 

504 

505@pytest.mark.asyncio() 

506async def test_ok_6_202(async_client, tmp_path): 

507 """ 

508 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

509 

510 Arguments: 

511 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

512 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

513 """ 

514 # Assert HTTP client is created. 

515 assert async_client 

516 

517 # Create dummy projects. 

518 create_dummy_projects( 

519 tmp_path=tmp_path, 

520 list_of_dummy_project_ids=[ 

521 "1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS", 

522 ], 

523 ) 

524 

525 # Assert route `POST /api/projects/{project_id}/modelization` works. 

526 response_post = await async_client.post( 

527 url="/api/projects/1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS/modelization" 

528 ) 

529 assert response_post.status_code == 202 

530 assert response_post.json() == { 

531 "project_id": "1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS", 

532 "detail": "In project with id '1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS', the modelization update task has been requested and is waiting for a background task.", 

533 } 

534 

535 # Assert route `GET /api/projects/{project_id}/status` is update. 

536 response_get = await async_client.get( 

537 url="/api/projects/1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS/status" 

538 ) 

539 assert response_get.status_code == 200 

540 assert response_get.json()["status"]["iteration_id"] == 1 

541 assert response_get.json()["status"]["state"] in { 

542 "ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS", 

543 "ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS", 

544 "ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS", 

545 } 

546 if response_get.json()["status"]["state"] in { 

547 "ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS", 

548 "ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS", 

549 }: # pragma: nocover 

550 assert response_get.json()["status"]["task"] is not None 

551 else: # pragma: nocover 

552 assert response_get.json()["status"]["task"] is None 

553 

554 

555# ============================================================================== 

556# test_ok_7_202 

557# ============================================================================== 

558 

559 

560@pytest.mark.asyncio() 

561async def test_ok_7_202(async_client, tmp_path): 

562 """ 

563 Test the `POST /api/projects/{project_id}/modelization` route with good state. 

564 

565 Arguments: 

566 async_client: Fixture providing an HTTP client, declared in `conftest.py`. 

567 tmp_path: The temporary path given for this test, declared in `conftest.py`. 

568 """ 

569 # Assert HTTP client is created. 

570 assert async_client 

571 

572 # Create dummy projects. 

573 create_dummy_projects( 

574 tmp_path=tmp_path, 

575 list_of_dummy_project_ids=[ 

576 "1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS", 

577 ], 

578 ) 

579 

580 # Assert route `POST /api/projects/{project_id}/modelization` works. 

581 response_post = await async_client.post( 

582 url="/api/projects/1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS/modelization" 

583 ) 

584 assert response_post.status_code == 202 

585 assert response_post.json() == { 

586 "project_id": "1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS", 

587 "detail": "In project with id '1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS', the modelization update task has been requested and is waiting for a background task.", 

588 } 

589 

590 # Assert route `GET /api/projects/{project_id}/status` is update. 

591 response_get = await async_client.get( 

592 url="/api/projects/1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS/status" 

593 ) 

594 assert response_get.status_code == 200 

595 assert response_get.json()["status"]["iteration_id"] == 1 

596 assert response_get.json()["status"]["state"] in { 

597 "ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS", 

598 "ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS", 

599 "ANNOTATION_WITH_UPTODATE_MODELIZATION", 

600 } 

601 if response_get.json()["status"]["state"] in { 

602 "ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS", 

603 "ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS", 

604 }: # pragma: nocover 

605 assert response_get.json()["status"]["task"] is not None 

606 else: # pragma: nocover 

607 assert response_get.json()["status"]["task"] is None