Coverage for tests/test_path.py: 100%

303 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from dirty_equals import IsDict 1abcdef

2from fastapi.testclient import TestClient 1abcdef

3 

4from .main import app 1abcdef

5 

6client = TestClient(app) 1abcdef

7 

8 

9def test_text_get(): 1abcdef

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

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

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

13 

14 

15def test_nonexistent(): 1abcdef

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

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

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

19 

20 

21def test_path_foobar(): 1abcdef

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

23 assert response.status_code == 200 1stuvwx

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

25 

26 

27def test_path_str_foobar(): 1abcdef

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

29 assert response.status_code == 200 1yzABCD

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

31 

32 

33def test_path_str_42(): 1abcdef

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

35 assert response.status_code == 200 1EFGHIJ

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

37 

38 

39def test_path_str_True(): 1abcdef

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

41 assert response.status_code == 200 1KLMNOP

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

43 

44 

45def test_path_int_foobar(): 1abcdef

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

47 assert response.status_code == 422 1QRSTUV

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

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(): 1abcdef

74 response = client.get("/path/int/True") 1WXYZ01

75 assert response.status_code == 422 1WXYZ01

76 assert response.json() == IsDict( 1WXYZ01

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(): 1abcdef

102 response = client.get("/path/int/42") 1234567

103 assert response.status_code == 200 1234567

104 assert response.json() == 42 1234567

105 

106 

107def test_path_int_42_5(): 1abcdef

108 response = client.get("/path/int/42.5") 189!#$%

109 assert response.status_code == 422 189!#$%

110 assert response.json() == IsDict( 189!#$%

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(): 1abcdef

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(): 1abcdef

164 response = client.get("/path/float/True") 1-./:;=

165 assert response.status_code == 422 1-./:;=

166 assert response.json() == IsDict( 1-./:;=

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(): 1abcdef

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

193 assert response.status_code == 200 1?@[]^_

194 assert response.json() == 42 1?@[]^_

195 

196 

197def test_path_float_42_5(): 1abcdef

198 response = client.get("/path/float/42.5") 2` { | } ~ ab

199 assert response.status_code == 200 2` { | } ~ ab

200 assert response.json() == 42.5 2` { | } ~ ab

201 

202 

203def test_path_bool_foobar(): 1abcdef

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

205 assert response.status_code == 422 2bbcbdbebfbgb

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

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(): 1abcdef

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

233 assert response.status_code == 200 2hbibjbkblbmb

234 assert response.json() is True 2hbibjbkblbmb

235 

236 

237def test_path_bool_42(): 1abcdef

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

239 assert response.status_code == 422 2nbobpbqbrbsb

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

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(): 1abcdef

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

267 assert response.status_code == 422 2tbubvbwbxbyb

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

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(): 1abcdef

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

295 assert response.status_code == 200 2zbAbBbCbDbEb

296 assert response.json() is True 2zbAbBbCbDbEb

297 

298 

299def test_path_bool_0(): 1abcdef

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

301 assert response.status_code == 200 2FbGbHbIbJbKb

302 assert response.json() is False 2FbGbHbIbJbKb

303 

304 

305def test_path_bool_true(): 1abcdef

306 response = client.get("/path/bool/true") 2LbMbNbObPbQb

307 assert response.status_code == 200 2LbMbNbObPbQb

308 assert response.json() is True 2LbMbNbObPbQb

309 

310 

311def test_path_bool_False(): 1abcdef

312 response = client.get("/path/bool/False") 2RbSbTbUbVbWb

313 assert response.status_code == 200 2RbSbTbUbVbWb

314 assert response.json() is False 2RbSbTbUbVbWb

315 

316 

317def test_path_bool_false(): 1abcdef

318 response = client.get("/path/bool/false") 2XbYbZb0b1b2b

319 assert response.status_code == 200 2XbYbZb0b1b2b

320 assert response.json() is False 2XbYbZb0b1b2b

321 

322 

323def test_path_param_foo(): 1abcdef

324 response = client.get("/path/param/foo") 23b4b5b6b7b8b

325 assert response.status_code == 200 23b4b5b6b7b8b

326 assert response.json() == "foo" 23b4b5b6b7b8b

327 

328 

329def test_path_param_minlength_foo(): 1abcdef

330 response = client.get("/path/param-minlength/foo") 29b!b#b$b%b'b

331 assert response.status_code == 200 29b!b#b$b%b'b

332 assert response.json() == "foo" 29b!b#b$b%b'b

333 

334 

335def test_path_param_minlength_fo(): 1abcdef

336 response = client.get("/path/param-minlength/fo") 2(b)b*b+b,b-b

337 assert response.status_code == 422 2(b)b*b+b,b-b

338 assert response.json() == IsDict( 2(b)b*b+b,b-b

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(): 1abcdef

366 response = client.get("/path/param-maxlength/foo") 2.b/b:b;b=b?b

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

368 assert response.json() == "foo" 2.b/b:b;b=b?b

369 

370 

371def test_path_param_maxlength_foobar(): 1abcdef

372 response = client.get("/path/param-maxlength/foobar") 2@b[b]b^b_b`b

373 assert response.status_code == 422 2@b[b]b^b_b`b

374 assert response.json() == IsDict( 2@b[b]b^b_b`b

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(): 1abcdef

402 response = client.get("/path/param-min_maxlength/foo") 2{b|b}b~bacbc

403 assert response.status_code == 200 2{b|b}b~bacbc

404 assert response.json() == "foo" 2{b|b}b~bacbc

405 

406 

407def test_path_param_min_maxlength_foobar(): 1abcdef

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

409 assert response.status_code == 422 2ccdcecfcgchc

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

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(): 1abcdef

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

439 assert response.status_code == 422 2icjckclcmcnc

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

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(): 1abcdef

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

468 assert response.status_code == 200 2ocpcqcrcsctc

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

470 

471 

472def test_path_param_gt_2(): 1abcdef

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

474 assert response.status_code == 422 2ucvcwcxcyczc

475 assert response.json() == IsDict( 2ucvcwcxcyczc

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(): 1abcdef

503 response = client.get("/path/param-gt0/0.05") 2AcBcCcDcEcFc

504 assert response.status_code == 200 2AcBcCcDcEcFc

505 assert response.json() == 0.05 2AcBcCcDcEcFc

506 

507 

508def test_path_param_gt0_0(): 1abcdef

509 response = client.get("/path/param-gt0/0") 2GcHcIcJcKcLc

510 assert response.status_code == 422 2GcHcIcJcKcLc

511 assert response.json() == IsDict( 2GcHcIcJcKcLc

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(): 1abcdef

539 response = client.get("/path/param-ge/42") 2McNcOcPcQcRc

540 assert response.status_code == 200 2McNcOcPcQcRc

541 assert response.json() == 42 2McNcOcPcQcRc

542 

543 

544def test_path_param_ge_3(): 1abcdef

545 response = client.get("/path/param-ge/3") 2ScTcUcVcWcXc

546 assert response.status_code == 200 2ScTcUcVcWcXc

547 assert response.json() == 3 2ScTcUcVcWcXc

548 

549 

550def test_path_param_ge_2(): 1abcdef

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

552 assert response.status_code == 422 2YcZc0c1c2c3c

553 assert response.json() == IsDict( 2YcZc0c1c2c3c

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(): 1abcdef

581 response = client.get("/path/param-lt/42") 24c5c6c7c8c9c

582 assert response.status_code == 422 24c5c6c7c8c9c

583 assert response.json() == IsDict( 24c5c6c7c8c9c

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(): 1abcdef

611 response = client.get("/path/param-lt/2") 2!c#c$c%c'c(c

612 assert response.status_code == 200 2!c#c$c%c'c(c

613 assert response.json() == 2 2!c#c$c%c'c(c

614 

615 

616def test_path_param_lt0__1(): 1abcdef

617 response = client.get("/path/param-lt0/-1") 2)c*c+c,c-c.c

618 assert response.status_code == 200 2)c*c+c,c-c.c

619 assert response.json() == -1 2)c*c+c,c-c.c

620 

621 

622def test_path_param_lt0_0(): 1abcdef

623 response = client.get("/path/param-lt0/0") 2/c:c;c=c?c@c

624 assert response.status_code == 422 2/c:c;c=c?c@c

625 assert response.json() == IsDict( 2/c:c;c=c?c@c

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(): 1abcdef

653 response = client.get("/path/param-le/42") 2[c]c^c_c`c{c

654 assert response.status_code == 422 2[c]c^c_c`c{c

655 assert response.json() == IsDict( 2[c]c^c_c`c{c

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(): 1abcdef

683 response = client.get("/path/param-le/3") 2|c}c~cadbdcd

684 assert response.status_code == 200 2|c}c~cadbdcd

685 assert response.json() == 3 2|c}c~cadbdcd

686 

687 

688def test_path_param_le_2(): 1abcdef

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

690 assert response.status_code == 200 2ddedfdgdhdid

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

692 

693 

694def test_path_param_lt_gt_2(): 1abcdef

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

696 assert response.status_code == 200 2jdkdldmdndod

697 assert response.json() == 2 2jdkdldmdndod

698 

699 

700def test_path_param_lt_gt_4(): 1abcdef

701 response = client.get("/path/param-lt-gt/4") 2pdqdrdsdtdud

702 assert response.status_code == 422 2pdqdrdsdtdud

703 assert response.json() == IsDict( 2pdqdrdsdtdud

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(): 1abcdef

731 response = client.get("/path/param-lt-gt/0") 2vdwdxdydzdAd

732 assert response.status_code == 422 2vdwdxdydzdAd

733 assert response.json() == IsDict( 2vdwdxdydzdAd

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(): 1abcdef

761 response = client.get("/path/param-le-ge/2") 2BdCdDdEdFdGd

762 assert response.status_code == 200 2BdCdDdEdFdGd

763 assert response.json() == 2 2BdCdDdEdFdGd

764 

765 

766def test_path_param_le_ge_1(): 1abcdef

767 response = client.get("/path/param-le-ge/1") 2ffgfhfifjfkf

768 assert response.status_code == 200 2ffgfhfifjfkf

769 

770 

771def test_path_param_le_ge_3(): 1abcdef

772 response = client.get("/path/param-le-ge/3") 2HdIdJdKdLdMd

773 assert response.status_code == 200 2HdIdJdKdLdMd

774 assert response.json() == 3 2HdIdJdKdLdMd

775 

776 

777def test_path_param_le_ge_4(): 1abcdef

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

779 assert response.status_code == 422 2NdOdPdQdRdSd

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

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(): 1abcdef

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

809 assert response.status_code == 200 2TdUdVdWdXdYd

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

811 

812 

813def test_path_param_lt_int_42(): 1abcdef

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

815 assert response.status_code == 422 2Zd0d1d2d3d4d

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

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(): 1abcdef

844 response = client.get("/path/param-lt-int/2.7") 25d6d7d8d9d!d

845 assert response.status_code == 422 25d6d7d8d9d!d

846 assert response.json() == IsDict( 25d6d7d8d9d!d

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(): 1abcdef

872 response = client.get("/path/param-gt-int/42") 2#d$d%d'd(d)d

873 assert response.status_code == 200 2#d$d%d'd(d)d

874 assert response.json() == 42 2#d$d%d'd(d)d

875 

876 

877def test_path_param_gt_int_2(): 1abcdef

878 response = client.get("/path/param-gt-int/2") 2*d+d,d-d.d/d

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

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

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(): 1abcdef

908 response = client.get("/path/param-gt-int/2.7") 2:d;d=d?d@d[d

909 assert response.status_code == 422 2:d;d=d?d@d[d

910 assert response.json() == IsDict( 2:d;d=d?d@d[d

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(): 1abcdef

936 response = client.get("/path/param-le-int/42") 2]d^d_d`d{d|d

937 assert response.status_code == 422 2]d^d_d`d{d|d

938 assert response.json() == IsDict( 2]d^d_d`d{d|d

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(): 1abcdef

966 response = client.get("/path/param-le-int/3") 2}d~daebecede

967 assert response.status_code == 200 2}d~daebecede

968 assert response.json() == 3 2}d~daebecede

969 

970 

971def test_path_param_le_int_2(): 1abcdef

972 response = client.get("/path/param-le-int/2") 2eefegeheieje

973 assert response.status_code == 200 2eefegeheieje

974 assert response.json() == 2 2eefegeheieje

975 

976 

977def test_path_param_le_int_2_7(): 1abcdef

978 response = client.get("/path/param-le-int/2.7") 2kelemeneoepe

979 assert response.status_code == 422 2kelemeneoepe

980 assert response.json() == IsDict( 2kelemeneoepe

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(): 1abcdef

1006 response = client.get("/path/param-ge-int/42") 2qereseteueve

1007 assert response.status_code == 200 2qereseteueve

1008 assert response.json() == 42 2qereseteueve

1009 

1010 

1011def test_path_param_ge_int_3(): 1abcdef

1012 response = client.get("/path/param-ge-int/3") 2wexeyezeAeBe

1013 assert response.status_code == 200 2wexeyezeAeBe

1014 assert response.json() == 3 2wexeyezeAeBe

1015 

1016 

1017def test_path_param_ge_int_2(): 1abcdef

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

1019 assert response.status_code == 422 2CeDeEeFeGeHe

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

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(): 1abcdef

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

1049 assert response.status_code == 422 2IeJeKeLeMeNe

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

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(): 1abcdef

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

1077 assert response.status_code == 200 2OePeQeReSeTe

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

1079 

1080 

1081def test_path_param_lt_gt_int_4(): 1abcdef

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

1083 assert response.status_code == 422 2UeVeWeXeYeZe

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

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(): 1abcdef

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

1113 assert response.status_code == 422 20e1e2e3e4e5e

1114 assert response.json() == IsDict( 20e1e2e3e4e5e

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(): 1abcdef

1142 response = client.get("/path/param-lt-gt-int/2.7") 26e7e8e9e!e#e

1143 assert response.status_code == 422 26e7e8e9e!e#e

1144 assert response.json() == IsDict( 26e7e8e9e!e#e

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(): 1abcdef

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

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

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

1173 

1174 

1175def test_path_param_le_ge_int_1(): 1abcdef

1176 response = client.get("/path/param-le-ge-int/1") 2+e,e-e.e/e:e

1177 assert response.status_code == 200 2+e,e-e.e/e:e

1178 assert response.json() == 1 2+e,e-e.e/e:e

1179 

1180 

1181def test_path_param_le_ge_int_3(): 1abcdef

1182 response = client.get("/path/param-le-ge-int/3") 2;e=e?e@e[e]e

1183 assert response.status_code == 200 2;e=e?e@e[e]e

1184 assert response.json() == 3 2;e=e?e@e[e]e

1185 

1186 

1187def test_path_param_le_ge_int_4(): 1abcdef

1188 response = client.get("/path/param-le-ge-int/4") 2^e_e`e{e|e}e

1189 assert response.status_code == 422 2^e_e`e{e|e}e

1190 assert response.json() == IsDict( 2^e_e`e{e|e}e

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(): 1abcdef

1218 response = client.get("/path/param-le-ge-int/2.7") 2~eafbfcfdfef

1219 assert response.status_code == 422 2~eafbfcfdfef

1220 assert response.json() == IsDict( 2~eafbfcfdfef

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 )