Coverage for tests/test_path.py: 100%

303 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from dirty_equals import IsDict 1abcdefg

2from fastapi.testclient import TestClient 1abcdefg

3 

4from .main import app 1abcdefg

5 

6client = TestClient(app) 1abcdefg

7 

8 

9def test_text_get(): 1abcdefg

10 response = client.get("/text") 1hijklmn

11 assert response.status_code == 200, response.text 1hijklmn

12 assert response.json() == "Hello World" 1hijklmn

13 

14 

15def test_nonexistent(): 1abcdefg

16 response = client.get("/nonexistent") 1opqrstu

17 assert response.status_code == 404, response.text 1opqrstu

18 assert response.json() == {"detail": "Not Found"} 1opqrstu

19 

20 

21def test_path_foobar(): 1abcdefg

22 response = client.get("/path/foobar") 1vwxyzAB

23 assert response.status_code == 200 1vwxyzAB

24 assert response.json() == "foobar" 1vwxyzAB

25 

26 

27def test_path_str_foobar(): 1abcdefg

28 response = client.get("/path/str/foobar") 1CDEFGHI

29 assert response.status_code == 200 1CDEFGHI

30 assert response.json() == "foobar" 1CDEFGHI

31 

32 

33def test_path_str_42(): 1abcdefg

34 response = client.get("/path/str/42") 1JKLMNOP

35 assert response.status_code == 200 1JKLMNOP

36 assert response.json() == "42" 1JKLMNOP

37 

38 

39def test_path_str_True(): 1abcdefg

40 response = client.get("/path/str/True") 1QRSTUVW

41 assert response.status_code == 200 1QRSTUVW

42 assert response.json() == "True" 1QRSTUVW

43 

44 

45def test_path_int_foobar(): 1abcdefg

46 response = client.get("/path/int/foobar") 1XYZ0123

47 assert response.status_code == 422 1XYZ0123

48 assert response.json() == IsDict( 1XYZ0123

49 { 

50 "detail": [ 

51 { 

52 "type": "int_parsing", 

53 "loc": ["path", "item_id"], 

54 "msg": "Input should be a valid integer, unable to parse string as an integer", 

55 "input": "foobar", 

56 } 

57 ] 

58 } 

59 ) | IsDict( 

60 # TODO: remove when deprecating Pydantic v1 

61 { 

62 "detail": [ 

63 { 

64 "loc": ["path", "item_id"], 

65 "msg": "value is not a valid integer", 

66 "type": "type_error.integer", 

67 } 

68 ] 

69 } 

70 ) 

71 

72 

73def test_path_int_True(): 1abcdefg

74 response = client.get("/path/int/True") 1456789!

75 assert response.status_code == 422 1456789!

76 assert response.json() == IsDict( 1456789!

77 { 

78 "detail": [ 

79 { 

80 "type": "int_parsing", 

81 "loc": ["path", "item_id"], 

82 "msg": "Input should be a valid integer, unable to parse string as an integer", 

83 "input": "True", 

84 } 

85 ] 

86 } 

87 ) | IsDict( 

88 # TODO: remove when deprecating Pydantic v1 

89 { 

90 "detail": [ 

91 { 

92 "loc": ["path", "item_id"], 

93 "msg": "value is not a valid integer", 

94 "type": "type_error.integer", 

95 } 

96 ] 

97 } 

98 ) 

99 

100 

101def test_path_int_42(): 1abcdefg

102 response = client.get("/path/int/42") 1#$%'()*

103 assert response.status_code == 200 1#$%'()*

104 assert response.json() == 42 1#$%'()*

105 

106 

107def test_path_int_42_5(): 1abcdefg

108 response = client.get("/path/int/42.5") 1+,-./:;

109 assert response.status_code == 422 1+,-./:;

110 assert response.json() == IsDict( 1+,-./:;

111 { 

112 "detail": [ 

113 { 

114 "type": "int_parsing", 

115 "loc": ["path", "item_id"], 

116 "msg": "Input should be a valid integer, unable to parse string as an integer", 

117 "input": "42.5", 

118 } 

119 ] 

120 } 

121 ) | IsDict( 

122 # TODO: remove when deprecating Pydantic v1 

123 { 

124 "detail": [ 

125 { 

126 "loc": ["path", "item_id"], 

127 "msg": "value is not a valid integer", 

128 "type": "type_error.integer", 

129 } 

130 ] 

131 } 

132 ) 

133 

134 

135def test_path_float_foobar(): 1abcdefg

136 response = client.get("/path/float/foobar") 1=?@[]^_

137 assert response.status_code == 422 1=?@[]^_

138 assert response.json() == IsDict( 1=?@[]^_

139 { 

140 "detail": [ 

141 { 

142 "type": "float_parsing", 

143 "loc": ["path", "item_id"], 

144 "msg": "Input should be a valid number, unable to parse string as a number", 

145 "input": "foobar", 

146 } 

147 ] 

148 } 

149 ) | IsDict( 

150 # TODO: remove when deprecating Pydantic v1 

151 { 

152 "detail": [ 

153 { 

154 "loc": ["path", "item_id"], 

155 "msg": "value is not a valid float", 

156 "type": "type_error.float", 

157 } 

158 ] 

159 } 

160 ) 

161 

162 

163def test_path_float_True(): 1abcdefg

164 response = client.get("/path/float/True") 2` { | } ~ abbb

165 assert response.status_code == 422 2` { | } ~ abbb

166 assert response.json() == IsDict( 2` { | } ~ abbb

167 { 

168 "detail": [ 

169 { 

170 "type": "float_parsing", 

171 "loc": ["path", "item_id"], 

172 "msg": "Input should be a valid number, unable to parse string as a number", 

173 "input": "True", 

174 } 

175 ] 

176 } 

177 ) | IsDict( 

178 # TODO: remove when deprecating Pydantic v1 

179 { 

180 "detail": [ 

181 { 

182 "loc": ["path", "item_id"], 

183 "msg": "value is not a valid float", 

184 "type": "type_error.float", 

185 } 

186 ] 

187 } 

188 ) 

189 

190 

191def test_path_float_42(): 1abcdefg

192 response = client.get("/path/float/42") 2cbdbebfbgbhbib

193 assert response.status_code == 200 2cbdbebfbgbhbib

194 assert response.json() == 42 2cbdbebfbgbhbib

195 

196 

197def test_path_float_42_5(): 1abcdefg

198 response = client.get("/path/float/42.5") 2jbkblbmbnbobpb

199 assert response.status_code == 200 2jbkblbmbnbobpb

200 assert response.json() == 42.5 2jbkblbmbnbobpb

201 

202 

203def test_path_bool_foobar(): 1abcdefg

204 response = client.get("/path/bool/foobar") 2qbrbsbtbubvbwb

205 assert response.status_code == 422 2qbrbsbtbubvbwb

206 assert response.json() == IsDict( 2qbrbsbtbubvbwb

207 { 

208 "detail": [ 

209 { 

210 "type": "bool_parsing", 

211 "loc": ["path", "item_id"], 

212 "msg": "Input should be a valid boolean, unable to interpret input", 

213 "input": "foobar", 

214 } 

215 ] 

216 } 

217 ) | IsDict( 

218 # TODO: remove when deprecating Pydantic v1 

219 { 

220 "detail": [ 

221 { 

222 "loc": ["path", "item_id"], 

223 "msg": "value could not be parsed to a boolean", 

224 "type": "type_error.bool", 

225 } 

226 ] 

227 } 

228 ) 

229 

230 

231def test_path_bool_True(): 1abcdefg

232 response = client.get("/path/bool/True") 2xbybzbAbBbCbDb

233 assert response.status_code == 200 2xbybzbAbBbCbDb

234 assert response.json() is True 2xbybzbAbBbCbDb

235 

236 

237def test_path_bool_42(): 1abcdefg

238 response = client.get("/path/bool/42") 2EbFbGbHbIbJbKb

239 assert response.status_code == 422 2EbFbGbHbIbJbKb

240 assert response.json() == IsDict( 2EbFbGbHbIbJbKb

241 { 

242 "detail": [ 

243 { 

244 "type": "bool_parsing", 

245 "loc": ["path", "item_id"], 

246 "msg": "Input should be a valid boolean, unable to interpret input", 

247 "input": "42", 

248 } 

249 ] 

250 } 

251 ) | IsDict( 

252 # TODO: remove when deprecating Pydantic v1 

253 { 

254 "detail": [ 

255 { 

256 "loc": ["path", "item_id"], 

257 "msg": "value could not be parsed to a boolean", 

258 "type": "type_error.bool", 

259 } 

260 ] 

261 } 

262 ) 

263 

264 

265def test_path_bool_42_5(): 1abcdefg

266 response = client.get("/path/bool/42.5") 2LbMbNbObPbQbRb

267 assert response.status_code == 422 2LbMbNbObPbQbRb

268 assert response.json() == IsDict( 2LbMbNbObPbQbRb

269 { 

270 "detail": [ 

271 { 

272 "type": "bool_parsing", 

273 "loc": ["path", "item_id"], 

274 "msg": "Input should be a valid boolean, unable to interpret input", 

275 "input": "42.5", 

276 } 

277 ] 

278 } 

279 ) | IsDict( 

280 # TODO: remove when deprecating Pydantic v1 

281 { 

282 "detail": [ 

283 { 

284 "loc": ["path", "item_id"], 

285 "msg": "value could not be parsed to a boolean", 

286 "type": "type_error.bool", 

287 } 

288 ] 

289 } 

290 ) 

291 

292 

293def test_path_bool_1(): 1abcdefg

294 response = client.get("/path/bool/1") 2SbTbUbVbWbXbYb

295 assert response.status_code == 200 2SbTbUbVbWbXbYb

296 assert response.json() is True 2SbTbUbVbWbXbYb

297 

298 

299def test_path_bool_0(): 1abcdefg

300 response = client.get("/path/bool/0") 2Zb0b1b2b3b4b5b

301 assert response.status_code == 200 2Zb0b1b2b3b4b5b

302 assert response.json() is False 2Zb0b1b2b3b4b5b

303 

304 

305def test_path_bool_true(): 1abcdefg

306 response = client.get("/path/bool/true") 26b7b8b9b!b#b$b

307 assert response.status_code == 200 26b7b8b9b!b#b$b

308 assert response.json() is True 26b7b8b9b!b#b$b

309 

310 

311def test_path_bool_False(): 1abcdefg

312 response = client.get("/path/bool/False") 2%b'b(b)b*b+b,b

313 assert response.status_code == 200 2%b'b(b)b*b+b,b

314 assert response.json() is False 2%b'b(b)b*b+b,b

315 

316 

317def test_path_bool_false(): 1abcdefg

318 response = client.get("/path/bool/false") 2-b.b/b:b;b=b?b

319 assert response.status_code == 200 2-b.b/b:b;b=b?b

320 assert response.json() is False 2-b.b/b:b;b=b?b

321 

322 

323def test_path_param_foo(): 1abcdefg

324 response = client.get("/path/param/foo") 2@b[b]b^b_b`b{b

325 assert response.status_code == 200 2@b[b]b^b_b`b{b

326 assert response.json() == "foo" 2@b[b]b^b_b`b{b

327 

328 

329def test_path_param_minlength_foo(): 1abcdefg

330 response = client.get("/path/param-minlength/foo") 2|b}b~bacbcccdc

331 assert response.status_code == 200 2|b}b~bacbcccdc

332 assert response.json() == "foo" 2|b}b~bacbcccdc

333 

334 

335def test_path_param_minlength_fo(): 1abcdefg

336 response = client.get("/path/param-minlength/fo") 2ecfcgchcicjckc

337 assert response.status_code == 422 2ecfcgchcicjckc

338 assert response.json() == IsDict( 2ecfcgchcicjckc

339 { 

340 "detail": [ 

341 { 

342 "type": "string_too_short", 

343 "loc": ["path", "item_id"], 

344 "msg": "String should have at least 3 characters", 

345 "input": "fo", 

346 "ctx": {"min_length": 3}, 

347 } 

348 ] 

349 } 

350 ) | IsDict( 

351 # TODO: remove when deprecating Pydantic v1 

352 { 

353 "detail": [ 

354 { 

355 "loc": ["path", "item_id"], 

356 "msg": "ensure this value has at least 3 characters", 

357 "type": "value_error.any_str.min_length", 

358 "ctx": {"limit_value": 3}, 

359 } 

360 ] 

361 } 

362 ) 

363 

364 

365def test_path_param_maxlength_foo(): 1abcdefg

366 response = client.get("/path/param-maxlength/foo") 2lcmcncocpcqcrc

367 assert response.status_code == 200 2lcmcncocpcqcrc

368 assert response.json() == "foo" 2lcmcncocpcqcrc

369 

370 

371def test_path_param_maxlength_foobar(): 1abcdefg

372 response = client.get("/path/param-maxlength/foobar") 2sctcucvcwcxcyc

373 assert response.status_code == 422 2sctcucvcwcxcyc

374 assert response.json() == IsDict( 2sctcucvcwcxcyc

375 { 

376 "detail": [ 

377 { 

378 "type": "string_too_long", 

379 "loc": ["path", "item_id"], 

380 "msg": "String should have at most 3 characters", 

381 "input": "foobar", 

382 "ctx": {"max_length": 3}, 

383 } 

384 ] 

385 } 

386 ) | IsDict( 

387 # TODO: remove when deprecating Pydantic v1 

388 { 

389 "detail": [ 

390 { 

391 "loc": ["path", "item_id"], 

392 "msg": "ensure this value has at most 3 characters", 

393 "type": "value_error.any_str.max_length", 

394 "ctx": {"limit_value": 3}, 

395 } 

396 ] 

397 } 

398 ) 

399 

400 

401def test_path_param_min_maxlength_foo(): 1abcdefg

402 response = client.get("/path/param-min_maxlength/foo") 2zcAcBcCcDcEcFc

403 assert response.status_code == 200 2zcAcBcCcDcEcFc

404 assert response.json() == "foo" 2zcAcBcCcDcEcFc

405 

406 

407def test_path_param_min_maxlength_foobar(): 1abcdefg

408 response = client.get("/path/param-min_maxlength/foobar") 2GcHcIcJcKcLcMc

409 assert response.status_code == 422 2GcHcIcJcKcLcMc

410 assert response.json() == IsDict( 2GcHcIcJcKcLcMc

411 { 

412 "detail": [ 

413 { 

414 "type": "string_too_long", 

415 "loc": ["path", "item_id"], 

416 "msg": "String should have at most 3 characters", 

417 "input": "foobar", 

418 "ctx": {"max_length": 3}, 

419 } 

420 ] 

421 } 

422 ) | IsDict( 

423 # TODO: remove when deprecating Pydantic v1 

424 { 

425 "detail": [ 

426 { 

427 "loc": ["path", "item_id"], 

428 "msg": "ensure this value has at most 3 characters", 

429 "type": "value_error.any_str.max_length", 

430 "ctx": {"limit_value": 3}, 

431 } 

432 ] 

433 } 

434 ) 

435 

436 

437def test_path_param_min_maxlength_f(): 1abcdefg

438 response = client.get("/path/param-min_maxlength/f") 2NcOcPcQcRcScTc

439 assert response.status_code == 422 2NcOcPcQcRcScTc

440 assert response.json() == IsDict( 2NcOcPcQcRcScTc

441 { 

442 "detail": [ 

443 { 

444 "type": "string_too_short", 

445 "loc": ["path", "item_id"], 

446 "msg": "String should have at least 2 characters", 

447 "input": "f", 

448 "ctx": {"min_length": 2}, 

449 } 

450 ] 

451 } 

452 ) | IsDict( 

453 { 

454 "detail": [ 

455 { 

456 "loc": ["path", "item_id"], 

457 "msg": "ensure this value has at least 2 characters", 

458 "type": "value_error.any_str.min_length", 

459 "ctx": {"limit_value": 2}, 

460 } 

461 ] 

462 } 

463 ) 

464 

465 

466def test_path_param_gt_42(): 1abcdefg

467 response = client.get("/path/param-gt/42") 2UcVcWcXcYcZc0c

468 assert response.status_code == 200 2UcVcWcXcYcZc0c

469 assert response.json() == 42 2UcVcWcXcYcZc0c

470 

471 

472def test_path_param_gt_2(): 1abcdefg

473 response = client.get("/path/param-gt/2") 21c2c3c4c5c6c7c

474 assert response.status_code == 422 21c2c3c4c5c6c7c

475 assert response.json() == IsDict( 21c2c3c4c5c6c7c

476 { 

477 "detail": [ 

478 { 

479 "type": "greater_than", 

480 "loc": ["path", "item_id"], 

481 "msg": "Input should be greater than 3", 

482 "input": "2", 

483 "ctx": {"gt": 3.0}, 

484 } 

485 ] 

486 } 

487 ) | IsDict( 

488 # TODO: remove when deprecating Pydantic v1 

489 { 

490 "detail": [ 

491 { 

492 "loc": ["path", "item_id"], 

493 "msg": "ensure this value is greater than 3", 

494 "type": "value_error.number.not_gt", 

495 "ctx": {"limit_value": 3}, 

496 } 

497 ] 

498 } 

499 ) 

500 

501 

502def test_path_param_gt0_0_05(): 1abcdefg

503 response = client.get("/path/param-gt0/0.05") 28c9c!c#c$c%c'c

504 assert response.status_code == 200 28c9c!c#c$c%c'c

505 assert response.json() == 0.05 28c9c!c#c$c%c'c

506 

507 

508def test_path_param_gt0_0(): 1abcdefg

509 response = client.get("/path/param-gt0/0") 2(c)c*c+c,c-c.c

510 assert response.status_code == 422 2(c)c*c+c,c-c.c

511 assert response.json() == IsDict( 2(c)c*c+c,c-c.c

512 { 

513 "detail": [ 

514 { 

515 "type": "greater_than", 

516 "loc": ["path", "item_id"], 

517 "msg": "Input should be greater than 0", 

518 "input": "0", 

519 "ctx": {"gt": 0.0}, 

520 } 

521 ] 

522 } 

523 ) | IsDict( 

524 # TODO: remove when deprecating Pydantic v1 

525 { 

526 "detail": [ 

527 { 

528 "loc": ["path", "item_id"], 

529 "msg": "ensure this value is greater than 0", 

530 "type": "value_error.number.not_gt", 

531 "ctx": {"limit_value": 0}, 

532 } 

533 ] 

534 } 

535 ) 

536 

537 

538def test_path_param_ge_42(): 1abcdefg

539 response = client.get("/path/param-ge/42") 2/c:c;c=c?c@c[c

540 assert response.status_code == 200 2/c:c;c=c?c@c[c

541 assert response.json() == 42 2/c:c;c=c?c@c[c

542 

543 

544def test_path_param_ge_3(): 1abcdefg

545 response = client.get("/path/param-ge/3") 2]c^c_c`c{c|c}c

546 assert response.status_code == 200 2]c^c_c`c{c|c}c

547 assert response.json() == 3 2]c^c_c`c{c|c}c

548 

549 

550def test_path_param_ge_2(): 1abcdefg

551 response = client.get("/path/param-ge/2") 2~cadbdcdddedfd

552 assert response.status_code == 422 2~cadbdcdddedfd

553 assert response.json() == IsDict( 2~cadbdcdddedfd

554 { 

555 "detail": [ 

556 { 

557 "type": "greater_than_equal", 

558 "loc": ["path", "item_id"], 

559 "msg": "Input should be greater than or equal to 3", 

560 "input": "2", 

561 "ctx": {"ge": 3.0}, 

562 } 

563 ] 

564 } 

565 ) | IsDict( 

566 # TODO: remove when deprecating Pydantic v1 

567 { 

568 "detail": [ 

569 { 

570 "loc": ["path", "item_id"], 

571 "msg": "ensure this value is greater than or equal to 3", 

572 "type": "value_error.number.not_ge", 

573 "ctx": {"limit_value": 3}, 

574 } 

575 ] 

576 } 

577 ) 

578 

579 

580def test_path_param_lt_42(): 1abcdefg

581 response = client.get("/path/param-lt/42") 2gdhdidjdkdldmd

582 assert response.status_code == 422 2gdhdidjdkdldmd

583 assert response.json() == IsDict( 2gdhdidjdkdldmd

584 { 

585 "detail": [ 

586 { 

587 "type": "less_than", 

588 "loc": ["path", "item_id"], 

589 "msg": "Input should be less than 3", 

590 "input": "42", 

591 "ctx": {"lt": 3.0}, 

592 } 

593 ] 

594 } 

595 ) | IsDict( 

596 # TODO: remove when deprecating Pydantic v1 

597 { 

598 "detail": [ 

599 { 

600 "loc": ["path", "item_id"], 

601 "msg": "ensure this value is less than 3", 

602 "type": "value_error.number.not_lt", 

603 "ctx": {"limit_value": 3}, 

604 } 

605 ] 

606 } 

607 ) 

608 

609 

610def test_path_param_lt_2(): 1abcdefg

611 response = client.get("/path/param-lt/2") 2ndodpdqdrdsdtd

612 assert response.status_code == 200 2ndodpdqdrdsdtd

613 assert response.json() == 2 2ndodpdqdrdsdtd

614 

615 

616def test_path_param_lt0__1(): 1abcdefg

617 response = client.get("/path/param-lt0/-1") 2udvdwdxdydzdAd

618 assert response.status_code == 200 2udvdwdxdydzdAd

619 assert response.json() == -1 2udvdwdxdydzdAd

620 

621 

622def test_path_param_lt0_0(): 1abcdefg

623 response = client.get("/path/param-lt0/0") 2BdCdDdEdFdGdHd

624 assert response.status_code == 422 2BdCdDdEdFdGdHd

625 assert response.json() == IsDict( 2BdCdDdEdFdGdHd

626 { 

627 "detail": [ 

628 { 

629 "type": "less_than", 

630 "loc": ["path", "item_id"], 

631 "msg": "Input should be less than 0", 

632 "input": "0", 

633 "ctx": {"lt": 0.0}, 

634 } 

635 ] 

636 } 

637 ) | IsDict( 

638 # TODO: remove when deprecating Pydantic v1 

639 { 

640 "detail": [ 

641 { 

642 "loc": ["path", "item_id"], 

643 "msg": "ensure this value is less than 0", 

644 "type": "value_error.number.not_lt", 

645 "ctx": {"limit_value": 0}, 

646 } 

647 ] 

648 } 

649 ) 

650 

651 

652def test_path_param_le_42(): 1abcdefg

653 response = client.get("/path/param-le/42") 2IdJdKdLdMdNdOd

654 assert response.status_code == 422 2IdJdKdLdMdNdOd

655 assert response.json() == IsDict( 2IdJdKdLdMdNdOd

656 { 

657 "detail": [ 

658 { 

659 "type": "less_than_equal", 

660 "loc": ["path", "item_id"], 

661 "msg": "Input should be less than or equal to 3", 

662 "input": "42", 

663 "ctx": {"le": 3.0}, 

664 } 

665 ] 

666 } 

667 ) | IsDict( 

668 # TODO: remove when deprecating Pydantic v1 

669 { 

670 "detail": [ 

671 { 

672 "loc": ["path", "item_id"], 

673 "msg": "ensure this value is less than or equal to 3", 

674 "type": "value_error.number.not_le", 

675 "ctx": {"limit_value": 3}, 

676 } 

677 ] 

678 } 

679 ) 

680 

681 

682def test_path_param_le_3(): 1abcdefg

683 response = client.get("/path/param-le/3") 2PdQdRdSdTdUdVd

684 assert response.status_code == 200 2PdQdRdSdTdUdVd

685 assert response.json() == 3 2PdQdRdSdTdUdVd

686 

687 

688def test_path_param_le_2(): 1abcdefg

689 response = client.get("/path/param-le/2") 2WdXdYdZd0d1d2d

690 assert response.status_code == 200 2WdXdYdZd0d1d2d

691 assert response.json() == 2 2WdXdYdZd0d1d2d

692 

693 

694def test_path_param_lt_gt_2(): 1abcdefg

695 response = client.get("/path/param-lt-gt/2") 23d4d5d6d7d8d9d

696 assert response.status_code == 200 23d4d5d6d7d8d9d

697 assert response.json() == 2 23d4d5d6d7d8d9d

698 

699 

700def test_path_param_lt_gt_4(): 1abcdefg

701 response = client.get("/path/param-lt-gt/4") 2!d#d$d%d'd(d)d

702 assert response.status_code == 422 2!d#d$d%d'd(d)d

703 assert response.json() == IsDict( 2!d#d$d%d'd(d)d

704 { 

705 "detail": [ 

706 { 

707 "type": "less_than", 

708 "loc": ["path", "item_id"], 

709 "msg": "Input should be less than 3", 

710 "input": "4", 

711 "ctx": {"lt": 3.0}, 

712 } 

713 ] 

714 } 

715 ) | IsDict( 

716 # TODO: remove when deprecating Pydantic v1 

717 { 

718 "detail": [ 

719 { 

720 "loc": ["path", "item_id"], 

721 "msg": "ensure this value is less than 3", 

722 "type": "value_error.number.not_lt", 

723 "ctx": {"limit_value": 3}, 

724 } 

725 ] 

726 } 

727 ) 

728 

729 

730def test_path_param_lt_gt_0(): 1abcdefg

731 response = client.get("/path/param-lt-gt/0") 2*d+d,d-d.d/d:d

732 assert response.status_code == 422 2*d+d,d-d.d/d:d

733 assert response.json() == IsDict( 2*d+d,d-d.d/d:d

734 { 

735 "detail": [ 

736 { 

737 "type": "greater_than", 

738 "loc": ["path", "item_id"], 

739 "msg": "Input should be greater than 1", 

740 "input": "0", 

741 "ctx": {"gt": 1.0}, 

742 } 

743 ] 

744 } 

745 ) | IsDict( 

746 # TODO: remove when deprecating Pydantic v1 

747 { 

748 "detail": [ 

749 { 

750 "loc": ["path", "item_id"], 

751 "msg": "ensure this value is greater than 1", 

752 "type": "value_error.number.not_gt", 

753 "ctx": {"limit_value": 1}, 

754 } 

755 ] 

756 } 

757 ) 

758 

759 

760def test_path_param_le_ge_2(): 1abcdefg

761 response = client.get("/path/param-le-ge/2") 2;d=d?d@d[d]d^d

762 assert response.status_code == 200 2;d=d?d@d[d]d^d

763 assert response.json() == 2 2;d=d?d@d[d]d^d

764 

765 

766def test_path_param_le_ge_1(): 1abcdefg

767 response = client.get("/path/param-le-ge/1") 2[f]f^f_f`f{f|f

768 assert response.status_code == 200 2[f]f^f_f`f{f|f

769 

770 

771def test_path_param_le_ge_3(): 1abcdefg

772 response = client.get("/path/param-le-ge/3") 2_d`d{d|d}d~dae

773 assert response.status_code == 200 2_d`d{d|d}d~dae

774 assert response.json() == 3 2_d`d{d|d}d~dae

775 

776 

777def test_path_param_le_ge_4(): 1abcdefg

778 response = client.get("/path/param-le-ge/4") 2becedeeefegehe

779 assert response.status_code == 422 2becedeeefegehe

780 assert response.json() == IsDict( 2becedeeefegehe

781 { 

782 "detail": [ 

783 { 

784 "type": "less_than_equal", 

785 "loc": ["path", "item_id"], 

786 "msg": "Input should be less than or equal to 3", 

787 "input": "4", 

788 "ctx": {"le": 3.0}, 

789 } 

790 ] 

791 } 

792 ) | IsDict( 

793 # TODO: remove when deprecating Pydantic v1 

794 { 

795 "detail": [ 

796 { 

797 "loc": ["path", "item_id"], 

798 "msg": "ensure this value is less than or equal to 3", 

799 "type": "value_error.number.not_le", 

800 "ctx": {"limit_value": 3}, 

801 } 

802 ] 

803 } 

804 ) 

805 

806 

807def test_path_param_lt_int_2(): 1abcdefg

808 response = client.get("/path/param-lt-int/2") 2iejekelemeneoe

809 assert response.status_code == 200 2iejekelemeneoe

810 assert response.json() == 2 2iejekelemeneoe

811 

812 

813def test_path_param_lt_int_42(): 1abcdefg

814 response = client.get("/path/param-lt-int/42") 2peqereseteueve

815 assert response.status_code == 422 2peqereseteueve

816 assert response.json() == IsDict( 2peqereseteueve

817 { 

818 "detail": [ 

819 { 

820 "type": "less_than", 

821 "loc": ["path", "item_id"], 

822 "msg": "Input should be less than 3", 

823 "input": "42", 

824 "ctx": {"lt": 3}, 

825 } 

826 ] 

827 } 

828 ) | IsDict( 

829 # TODO: remove when deprecating Pydantic v1 

830 { 

831 "detail": [ 

832 { 

833 "loc": ["path", "item_id"], 

834 "msg": "ensure this value is less than 3", 

835 "type": "value_error.number.not_lt", 

836 "ctx": {"limit_value": 3}, 

837 } 

838 ] 

839 } 

840 ) 

841 

842 

843def test_path_param_lt_int_2_7(): 1abcdefg

844 response = client.get("/path/param-lt-int/2.7") 2wexeyezeAeBeCe

845 assert response.status_code == 422 2wexeyezeAeBeCe

846 assert response.json() == IsDict( 2wexeyezeAeBeCe

847 { 

848 "detail": [ 

849 { 

850 "type": "int_parsing", 

851 "loc": ["path", "item_id"], 

852 "msg": "Input should be a valid integer, unable to parse string as an integer", 

853 "input": "2.7", 

854 } 

855 ] 

856 } 

857 ) | IsDict( 

858 # TODO: remove when deprecating Pydantic v1 

859 { 

860 "detail": [ 

861 { 

862 "loc": ["path", "item_id"], 

863 "msg": "value is not a valid integer", 

864 "type": "type_error.integer", 

865 } 

866 ] 

867 } 

868 ) 

869 

870 

871def test_path_param_gt_int_42(): 1abcdefg

872 response = client.get("/path/param-gt-int/42") 2DeEeFeGeHeIeJe

873 assert response.status_code == 200 2DeEeFeGeHeIeJe

874 assert response.json() == 42 2DeEeFeGeHeIeJe

875 

876 

877def test_path_param_gt_int_2(): 1abcdefg

878 response = client.get("/path/param-gt-int/2") 2KeLeMeNeOePeQe

879 assert response.status_code == 422 2KeLeMeNeOePeQe

880 assert response.json() == IsDict( 2KeLeMeNeOePeQe

881 { 

882 "detail": [ 

883 { 

884 "type": "greater_than", 

885 "loc": ["path", "item_id"], 

886 "msg": "Input should be greater than 3", 

887 "input": "2", 

888 "ctx": {"gt": 3}, 

889 } 

890 ] 

891 } 

892 ) | IsDict( 

893 # TODO: remove when deprecating Pydantic v1 

894 { 

895 "detail": [ 

896 { 

897 "loc": ["path", "item_id"], 

898 "msg": "ensure this value is greater than 3", 

899 "type": "value_error.number.not_gt", 

900 "ctx": {"limit_value": 3}, 

901 } 

902 ] 

903 } 

904 ) 

905 

906 

907def test_path_param_gt_int_2_7(): 1abcdefg

908 response = client.get("/path/param-gt-int/2.7") 2ReSeTeUeVeWeXe

909 assert response.status_code == 422 2ReSeTeUeVeWeXe

910 assert response.json() == IsDict( 2ReSeTeUeVeWeXe

911 { 

912 "detail": [ 

913 { 

914 "type": "int_parsing", 

915 "loc": ["path", "item_id"], 

916 "msg": "Input should be a valid integer, unable to parse string as an integer", 

917 "input": "2.7", 

918 } 

919 ] 

920 } 

921 ) | IsDict( 

922 # TODO: remove when deprecating Pydantic v1 

923 { 

924 "detail": [ 

925 { 

926 "loc": ["path", "item_id"], 

927 "msg": "value is not a valid integer", 

928 "type": "type_error.integer", 

929 } 

930 ] 

931 } 

932 ) 

933 

934 

935def test_path_param_le_int_42(): 1abcdefg

936 response = client.get("/path/param-le-int/42") 2YeZe0e1e2e3e4e

937 assert response.status_code == 422 2YeZe0e1e2e3e4e

938 assert response.json() == IsDict( 2YeZe0e1e2e3e4e

939 { 

940 "detail": [ 

941 { 

942 "type": "less_than_equal", 

943 "loc": ["path", "item_id"], 

944 "msg": "Input should be less than or equal to 3", 

945 "input": "42", 

946 "ctx": {"le": 3}, 

947 } 

948 ] 

949 } 

950 ) | IsDict( 

951 # TODO: remove when deprecating Pydantic v1 

952 { 

953 "detail": [ 

954 { 

955 "loc": ["path", "item_id"], 

956 "msg": "ensure this value is less than or equal to 3", 

957 "type": "value_error.number.not_le", 

958 "ctx": {"limit_value": 3}, 

959 } 

960 ] 

961 } 

962 ) 

963 

964 

965def test_path_param_le_int_3(): 1abcdefg

966 response = client.get("/path/param-le-int/3") 25e6e7e8e9e!e#e

967 assert response.status_code == 200 25e6e7e8e9e!e#e

968 assert response.json() == 3 25e6e7e8e9e!e#e

969 

970 

971def test_path_param_le_int_2(): 1abcdefg

972 response = client.get("/path/param-le-int/2") 2$e%e'e(e)e*e+e

973 assert response.status_code == 200 2$e%e'e(e)e*e+e

974 assert response.json() == 2 2$e%e'e(e)e*e+e

975 

976 

977def test_path_param_le_int_2_7(): 1abcdefg

978 response = client.get("/path/param-le-int/2.7") 2,e-e.e/e:e;e=e

979 assert response.status_code == 422 2,e-e.e/e:e;e=e

980 assert response.json() == IsDict( 2,e-e.e/e:e;e=e

981 { 

982 "detail": [ 

983 { 

984 "type": "int_parsing", 

985 "loc": ["path", "item_id"], 

986 "msg": "Input should be a valid integer, unable to parse string as an integer", 

987 "input": "2.7", 

988 } 

989 ] 

990 } 

991 ) | IsDict( 

992 # TODO: remove when deprecating Pydantic v1 

993 { 

994 "detail": [ 

995 { 

996 "loc": ["path", "item_id"], 

997 "msg": "value is not a valid integer", 

998 "type": "type_error.integer", 

999 } 

1000 ] 

1001 } 

1002 ) 

1003 

1004 

1005def test_path_param_ge_int_42(): 1abcdefg

1006 response = client.get("/path/param-ge-int/42") 2?e@e[e]e^e_e`e

1007 assert response.status_code == 200 2?e@e[e]e^e_e`e

1008 assert response.json() == 42 2?e@e[e]e^e_e`e

1009 

1010 

1011def test_path_param_ge_int_3(): 1abcdefg

1012 response = client.get("/path/param-ge-int/3") 2{e|e}e~eafbfcf

1013 assert response.status_code == 200 2{e|e}e~eafbfcf

1014 assert response.json() == 3 2{e|e}e~eafbfcf

1015 

1016 

1017def test_path_param_ge_int_2(): 1abcdefg

1018 response = client.get("/path/param-ge-int/2") 2dfefffgfhfifjf

1019 assert response.status_code == 422 2dfefffgfhfifjf

1020 assert response.json() == IsDict( 2dfefffgfhfifjf

1021 { 

1022 "detail": [ 

1023 { 

1024 "type": "greater_than_equal", 

1025 "loc": ["path", "item_id"], 

1026 "msg": "Input should be greater than or equal to 3", 

1027 "input": "2", 

1028 "ctx": {"ge": 3}, 

1029 } 

1030 ] 

1031 } 

1032 ) | IsDict( 

1033 # TODO: remove when deprecating Pydantic v1 

1034 { 

1035 "detail": [ 

1036 { 

1037 "loc": ["path", "item_id"], 

1038 "msg": "ensure this value is greater than or equal to 3", 

1039 "type": "value_error.number.not_ge", 

1040 "ctx": {"limit_value": 3}, 

1041 } 

1042 ] 

1043 } 

1044 ) 

1045 

1046 

1047def test_path_param_ge_int_2_7(): 1abcdefg

1048 response = client.get("/path/param-ge-int/2.7") 2kflfmfnfofpfqf

1049 assert response.status_code == 422 2kflfmfnfofpfqf

1050 assert response.json() == IsDict( 2kflfmfnfofpfqf

1051 { 

1052 "detail": [ 

1053 { 

1054 "type": "int_parsing", 

1055 "loc": ["path", "item_id"], 

1056 "msg": "Input should be a valid integer, unable to parse string as an integer", 

1057 "input": "2.7", 

1058 } 

1059 ] 

1060 } 

1061 ) | IsDict( 

1062 # TODO: remove when deprecating Pydantic v1 

1063 { 

1064 "detail": [ 

1065 { 

1066 "loc": ["path", "item_id"], 

1067 "msg": "value is not a valid integer", 

1068 "type": "type_error.integer", 

1069 } 

1070 ] 

1071 } 

1072 ) 

1073 

1074 

1075def test_path_param_lt_gt_int_2(): 1abcdefg

1076 response = client.get("/path/param-lt-gt-int/2") 2rfsftfufvfwfxf

1077 assert response.status_code == 200 2rfsftfufvfwfxf

1078 assert response.json() == 2 2rfsftfufvfwfxf

1079 

1080 

1081def test_path_param_lt_gt_int_4(): 1abcdefg

1082 response = client.get("/path/param-lt-gt-int/4") 2yfzfAfBfCfDfEf

1083 assert response.status_code == 422 2yfzfAfBfCfDfEf

1084 assert response.json() == IsDict( 2yfzfAfBfCfDfEf

1085 { 

1086 "detail": [ 

1087 { 

1088 "type": "less_than", 

1089 "loc": ["path", "item_id"], 

1090 "msg": "Input should be less than 3", 

1091 "input": "4", 

1092 "ctx": {"lt": 3}, 

1093 } 

1094 ] 

1095 } 

1096 ) | IsDict( 

1097 # TODO: remove when deprecating Pydantic v1 

1098 { 

1099 "detail": [ 

1100 { 

1101 "loc": ["path", "item_id"], 

1102 "msg": "ensure this value is less than 3", 

1103 "type": "value_error.number.not_lt", 

1104 "ctx": {"limit_value": 3}, 

1105 } 

1106 ] 

1107 } 

1108 ) 

1109 

1110 

1111def test_path_param_lt_gt_int_0(): 1abcdefg

1112 response = client.get("/path/param-lt-gt-int/0") 2FfGfHfIfJfKfLf

1113 assert response.status_code == 422 2FfGfHfIfJfKfLf

1114 assert response.json() == IsDict( 2FfGfHfIfJfKfLf

1115 { 

1116 "detail": [ 

1117 { 

1118 "type": "greater_than", 

1119 "loc": ["path", "item_id"], 

1120 "msg": "Input should be greater than 1", 

1121 "input": "0", 

1122 "ctx": {"gt": 1}, 

1123 } 

1124 ] 

1125 } 

1126 ) | IsDict( 

1127 # TODO: remove when deprecating Pydantic v1 

1128 { 

1129 "detail": [ 

1130 { 

1131 "loc": ["path", "item_id"], 

1132 "msg": "ensure this value is greater than 1", 

1133 "type": "value_error.number.not_gt", 

1134 "ctx": {"limit_value": 1}, 

1135 } 

1136 ] 

1137 } 

1138 ) 

1139 

1140 

1141def test_path_param_lt_gt_int_2_7(): 1abcdefg

1142 response = client.get("/path/param-lt-gt-int/2.7") 2MfNfOfPfQfRfSf

1143 assert response.status_code == 422 2MfNfOfPfQfRfSf

1144 assert response.json() == IsDict( 2MfNfOfPfQfRfSf

1145 { 

1146 "detail": [ 

1147 { 

1148 "type": "int_parsing", 

1149 "loc": ["path", "item_id"], 

1150 "msg": "Input should be a valid integer, unable to parse string as an integer", 

1151 "input": "2.7", 

1152 } 

1153 ] 

1154 } 

1155 ) | IsDict( 

1156 # TODO: remove when deprecating Pydantic v1 

1157 { 

1158 "detail": [ 

1159 { 

1160 "loc": ["path", "item_id"], 

1161 "msg": "value is not a valid integer", 

1162 "type": "type_error.integer", 

1163 } 

1164 ] 

1165 } 

1166 ) 

1167 

1168 

1169def test_path_param_le_ge_int_2(): 1abcdefg

1170 response = client.get("/path/param-le-ge-int/2") 2TfUfVfWfXfYfZf

1171 assert response.status_code == 200 2TfUfVfWfXfYfZf

1172 assert response.json() == 2 2TfUfVfWfXfYfZf

1173 

1174 

1175def test_path_param_le_ge_int_1(): 1abcdefg

1176 response = client.get("/path/param-le-ge-int/1") 20f1f2f3f4f5f6f

1177 assert response.status_code == 200 20f1f2f3f4f5f6f

1178 assert response.json() == 1 20f1f2f3f4f5f6f

1179 

1180 

1181def test_path_param_le_ge_int_3(): 1abcdefg

1182 response = client.get("/path/param-le-ge-int/3") 27f8f9f!f#f$f%f

1183 assert response.status_code == 200 27f8f9f!f#f$f%f

1184 assert response.json() == 3 27f8f9f!f#f$f%f

1185 

1186 

1187def test_path_param_le_ge_int_4(): 1abcdefg

1188 response = client.get("/path/param-le-ge-int/4") 2'f(f)f*f+f,f-f

1189 assert response.status_code == 422 2'f(f)f*f+f,f-f

1190 assert response.json() == IsDict( 2'f(f)f*f+f,f-f

1191 { 

1192 "detail": [ 

1193 { 

1194 "type": "less_than_equal", 

1195 "loc": ["path", "item_id"], 

1196 "msg": "Input should be less than or equal to 3", 

1197 "input": "4", 

1198 "ctx": {"le": 3}, 

1199 } 

1200 ] 

1201 } 

1202 ) | IsDict( 

1203 # TODO: remove when deprecating Pydantic v1 

1204 { 

1205 "detail": [ 

1206 { 

1207 "loc": ["path", "item_id"], 

1208 "msg": "ensure this value is less than or equal to 3", 

1209 "type": "value_error.number.not_le", 

1210 "ctx": {"limit_value": 3}, 

1211 } 

1212 ] 

1213 } 

1214 ) 

1215 

1216 

1217def test_path_param_le_ge_int_2_7(): 1abcdefg

1218 response = client.get("/path/param-le-ge-int/2.7") 2.f/f:f;f=f?f@f

1219 assert response.status_code == 422 2.f/f:f;f=f?f@f

1220 assert response.json() == IsDict( 2.f/f:f;f=f?f@f

1221 { 

1222 "detail": [ 

1223 { 

1224 "type": "int_parsing", 

1225 "loc": ["path", "item_id"], 

1226 "msg": "Input should be a valid integer, unable to parse string as an integer", 

1227 "input": "2.7", 

1228 } 

1229 ] 

1230 } 

1231 ) | IsDict( 

1232 # TODO: remove when deprecating Pydantic v1 

1233 { 

1234 "detail": [ 

1235 { 

1236 "loc": ["path", "item_id"], 

1237 "msg": "value is not a valid integer", 

1238 "type": "type_error.integer", 

1239 } 

1240 ] 

1241 } 

1242 )