Coverage for tests / test_path.py: 100%

302 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from fastapi.testclient import TestClient 1abcd

2 

3from .main import app 1abcd

4 

5client = TestClient(app) 1abcd

6 

7 

8def test_text_get(): 1abcd

9 response = client.get("/text") 1efgh

10 assert response.status_code == 200, response.text 1efgh

11 assert response.json() == "Hello World" 1efgh

12 

13 

14def test_nonexistent(): 1abcd

15 response = client.get("/nonexistent") 1ijkl

16 assert response.status_code == 404, response.text 1ijkl

17 assert response.json() == {"detail": "Not Found"} 1ijkl

18 

19 

20def test_path_foobar(): 1abcd

21 response = client.get("/path/foobar") 1mnop

22 assert response.status_code == 200 1mnop

23 assert response.json() == "foobar" 1mnop

24 

25 

26def test_path_str_foobar(): 1abcd

27 response = client.get("/path/str/foobar") 1qrst

28 assert response.status_code == 200 1qrst

29 assert response.json() == "foobar" 1qrst

30 

31 

32def test_path_str_42(): 1abcd

33 response = client.get("/path/str/42") 1uvwx

34 assert response.status_code == 200 1uvwx

35 assert response.json() == "42" 1uvwx

36 

37 

38def test_path_str_True(): 1abcd

39 response = client.get("/path/str/True") 1yzAB

40 assert response.status_code == 200 1yzAB

41 assert response.json() == "True" 1yzAB

42 

43 

44def test_path_int_foobar(): 1abcd

45 response = client.get("/path/int/foobar") 1CDEF

46 assert response.status_code == 422 1CDEF

47 assert response.json() == { 1CDEF

48 "detail": [ 

49 { 

50 "type": "int_parsing", 

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

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

53 "input": "foobar", 

54 } 

55 ] 

56 } 

57 

58 

59def test_path_int_True(): 1abcd

60 response = client.get("/path/int/True") 1GHIJ

61 assert response.status_code == 422 1GHIJ

62 assert response.json() == { 1GHIJ

63 "detail": [ 

64 { 

65 "type": "int_parsing", 

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

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

68 "input": "True", 

69 } 

70 ] 

71 } 

72 

73 

74def test_path_int_42(): 1abcd

75 response = client.get("/path/int/42") 1KLMN

76 assert response.status_code == 200 1KLMN

77 assert response.json() == 42 1KLMN

78 

79 

80def test_path_int_42_5(): 1abcd

81 response = client.get("/path/int/42.5") 1OPQR

82 assert response.status_code == 422 1OPQR

83 assert response.json() == { 1OPQR

84 "detail": [ 

85 { 

86 "type": "int_parsing", 

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

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

89 "input": "42.5", 

90 } 

91 ] 

92 } 

93 

94 

95def test_path_float_foobar(): 1abcd

96 response = client.get("/path/float/foobar") 1STUV

97 assert response.status_code == 422 1STUV

98 assert response.json() == { 1STUV

99 "detail": [ 

100 { 

101 "type": "float_parsing", 

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

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

104 "input": "foobar", 

105 } 

106 ] 

107 } 

108 

109 

110def test_path_float_True(): 1abcd

111 response = client.get("/path/float/True") 1WXYZ

112 assert response.status_code == 422 1WXYZ

113 assert response.json() == { 1WXYZ

114 "detail": [ 

115 { 

116 "type": "float_parsing", 

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

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

119 "input": "True", 

120 } 

121 ] 

122 } 

123 

124 

125def test_path_float_42(): 1abcd

126 response = client.get("/path/float/42") 10123

127 assert response.status_code == 200 10123

128 assert response.json() == 42 10123

129 

130 

131def test_path_float_42_5(): 1abcd

132 response = client.get("/path/float/42.5") 14567

133 assert response.status_code == 200 14567

134 assert response.json() == 42.5 14567

135 

136 

137def test_path_bool_foobar(): 1abcd

138 response = client.get("/path/bool/foobar") 189!#

139 assert response.status_code == 422 189!#

140 assert response.json() == { 189!#

141 "detail": [ 

142 { 

143 "type": "bool_parsing", 

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

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

146 "input": "foobar", 

147 } 

148 ] 

149 } 

150 

151 

152def test_path_bool_True(): 1abcd

153 response = client.get("/path/bool/True") 1$%'(

154 assert response.status_code == 200 1$%'(

155 assert response.json() is True 1$%'(

156 

157 

158def test_path_bool_42(): 1abcd

159 response = client.get("/path/bool/42") 1)*+,

160 assert response.status_code == 422 1)*+,

161 assert response.json() == { 1)*+,

162 "detail": [ 

163 { 

164 "type": "bool_parsing", 

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

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

167 "input": "42", 

168 } 

169 ] 

170 } 

171 

172 

173def test_path_bool_42_5(): 1abcd

174 response = client.get("/path/bool/42.5") 1-./:

175 assert response.status_code == 422 1-./:

176 assert response.json() == { 1-./:

177 "detail": [ 

178 { 

179 "type": "bool_parsing", 

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

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

182 "input": "42.5", 

183 } 

184 ] 

185 } 

186 

187 

188def test_path_bool_1(): 1abcd

189 response = client.get("/path/bool/1") 1;=?@

190 assert response.status_code == 200 1;=?@

191 assert response.json() is True 1;=?@

192 

193 

194def test_path_bool_0(): 1abcd

195 response = client.get("/path/bool/0") 1[]^_

196 assert response.status_code == 200 1[]^_

197 assert response.json() is False 1[]^_

198 

199 

200def test_path_bool_true(): 1abcd

201 response = client.get("/path/bool/true") 1`{|}

202 assert response.status_code == 200 1`{|}

203 assert response.json() is True 1`{|}

204 

205 

206def test_path_bool_False(): 1abcd

207 response = client.get("/path/bool/False") 2~ abbbcb

208 assert response.status_code == 200 2~ abbbcb

209 assert response.json() is False 2~ abbbcb

210 

211 

212def test_path_bool_false(): 1abcd

213 response = client.get("/path/bool/false") 2dbebfbgb

214 assert response.status_code == 200 2dbebfbgb

215 assert response.json() is False 2dbebfbgb

216 

217 

218def test_path_param_foo(): 1abcd

219 response = client.get("/path/param/foo") 2hbibjbkb

220 assert response.status_code == 200 2hbibjbkb

221 assert response.json() == "foo" 2hbibjbkb

222 

223 

224def test_path_param_minlength_foo(): 1abcd

225 response = client.get("/path/param-minlength/foo") 2lbmbnbob

226 assert response.status_code == 200 2lbmbnbob

227 assert response.json() == "foo" 2lbmbnbob

228 

229 

230def test_path_param_minlength_fo(): 1abcd

231 response = client.get("/path/param-minlength/fo") 2pbqbrbsb

232 assert response.status_code == 422 2pbqbrbsb

233 assert response.json() == { 2pbqbrbsb

234 "detail": [ 

235 { 

236 "type": "string_too_short", 

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

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

239 "input": "fo", 

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

241 } 

242 ] 

243 } 

244 

245 

246def test_path_param_maxlength_foo(): 1abcd

247 response = client.get("/path/param-maxlength/foo") 2tbubvbwb

248 assert response.status_code == 200 2tbubvbwb

249 assert response.json() == "foo" 2tbubvbwb

250 

251 

252def test_path_param_maxlength_foobar(): 1abcd

253 response = client.get("/path/param-maxlength/foobar") 2xbybzbAb

254 assert response.status_code == 422 2xbybzbAb

255 assert response.json() == { 2xbybzbAb

256 "detail": [ 

257 { 

258 "type": "string_too_long", 

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

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

261 "input": "foobar", 

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

263 } 

264 ] 

265 } 

266 

267 

268def test_path_param_min_maxlength_foo(): 1abcd

269 response = client.get("/path/param-min_maxlength/foo") 2BbCbDbEb

270 assert response.status_code == 200 2BbCbDbEb

271 assert response.json() == "foo" 2BbCbDbEb

272 

273 

274def test_path_param_min_maxlength_foobar(): 1abcd

275 response = client.get("/path/param-min_maxlength/foobar") 2FbGbHbIb

276 assert response.status_code == 422 2FbGbHbIb

277 assert response.json() == { 2FbGbHbIb

278 "detail": [ 

279 { 

280 "type": "string_too_long", 

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

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

283 "input": "foobar", 

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

285 } 

286 ] 

287 } 

288 

289 

290def test_path_param_min_maxlength_f(): 1abcd

291 response = client.get("/path/param-min_maxlength/f") 2JbKbLbMb

292 assert response.status_code == 422 2JbKbLbMb

293 assert response.json() == { 2JbKbLbMb

294 "detail": [ 

295 { 

296 "type": "string_too_short", 

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

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

299 "input": "f", 

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

301 } 

302 ] 

303 } 

304 

305 

306def test_path_param_gt_42(): 1abcd

307 response = client.get("/path/param-gt/42") 2NbObPbQb

308 assert response.status_code == 200 2NbObPbQb

309 assert response.json() == 42 2NbObPbQb

310 

311 

312def test_path_param_gt_2(): 1abcd

313 response = client.get("/path/param-gt/2") 2RbSbTbUb

314 assert response.status_code == 422 2RbSbTbUb

315 assert response.json() == { 2RbSbTbUb

316 "detail": [ 

317 { 

318 "type": "greater_than", 

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

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

321 "input": "2", 

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

323 } 

324 ] 

325 } 

326 

327 

328def test_path_param_gt0_0_05(): 1abcd

329 response = client.get("/path/param-gt0/0.05") 2VbWbXbYb

330 assert response.status_code == 200 2VbWbXbYb

331 assert response.json() == 0.05 2VbWbXbYb

332 

333 

334def test_path_param_gt0_0(): 1abcd

335 response = client.get("/path/param-gt0/0") 2Zb0b1b2b

336 assert response.status_code == 422 2Zb0b1b2b

337 assert response.json() == { 2Zb0b1b2b

338 "detail": [ 

339 { 

340 "type": "greater_than", 

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

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

343 "input": "0", 

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

345 } 

346 ] 

347 } 

348 

349 

350def test_path_param_ge_42(): 1abcd

351 response = client.get("/path/param-ge/42") 23b4b5b6b

352 assert response.status_code == 200 23b4b5b6b

353 assert response.json() == 42 23b4b5b6b

354 

355 

356def test_path_param_ge_3(): 1abcd

357 response = client.get("/path/param-ge/3") 27b8b9b!b

358 assert response.status_code == 200 27b8b9b!b

359 assert response.json() == 3 27b8b9b!b

360 

361 

362def test_path_param_ge_2(): 1abcd

363 response = client.get("/path/param-ge/2") 2#b$b%b'b

364 assert response.status_code == 422 2#b$b%b'b

365 assert response.json() == { 2#b$b%b'b

366 "detail": [ 

367 { 

368 "type": "greater_than_equal", 

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

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

371 "input": "2", 

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

373 } 

374 ] 

375 } 

376 

377 

378def test_path_param_lt_42(): 1abcd

379 response = client.get("/path/param-lt/42") 2(b)b*b+b

380 assert response.status_code == 422 2(b)b*b+b

381 assert response.json() == { 2(b)b*b+b

382 "detail": [ 

383 { 

384 "type": "less_than", 

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

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

387 "input": "42", 

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

389 } 

390 ] 

391 } 

392 

393 

394def test_path_param_lt_2(): 1abcd

395 response = client.get("/path/param-lt/2") 2,b-b.b/b

396 assert response.status_code == 200 2,b-b.b/b

397 assert response.json() == 2 2,b-b.b/b

398 

399 

400def test_path_param_lt0__1(): 1abcd

401 response = client.get("/path/param-lt0/-1") 2:b;b=b?b

402 assert response.status_code == 200 2:b;b=b?b

403 assert response.json() == -1 2:b;b=b?b

404 

405 

406def test_path_param_lt0_0(): 1abcd

407 response = client.get("/path/param-lt0/0") 2@b[b]b^b

408 assert response.status_code == 422 2@b[b]b^b

409 assert response.json() == { 2@b[b]b^b

410 "detail": [ 

411 { 

412 "type": "less_than", 

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

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

415 "input": "0", 

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

417 } 

418 ] 

419 } 

420 

421 

422def test_path_param_le_42(): 1abcd

423 response = client.get("/path/param-le/42") 2_b`b{b|b

424 assert response.status_code == 422 2_b`b{b|b

425 assert response.json() == { 2_b`b{b|b

426 "detail": [ 

427 { 

428 "type": "less_than_equal", 

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

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

431 "input": "42", 

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

433 } 

434 ] 

435 } 

436 

437 

438def test_path_param_le_3(): 1abcd

439 response = client.get("/path/param-le/3") 2}b~bacbc

440 assert response.status_code == 200 2}b~bacbc

441 assert response.json() == 3 2}b~bacbc

442 

443 

444def test_path_param_le_2(): 1abcd

445 response = client.get("/path/param-le/2") 2ccdcecfc

446 assert response.status_code == 200 2ccdcecfc

447 assert response.json() == 2 2ccdcecfc

448 

449 

450def test_path_param_lt_gt_2(): 1abcd

451 response = client.get("/path/param-lt-gt/2") 2gchcicjc

452 assert response.status_code == 200 2gchcicjc

453 assert response.json() == 2 2gchcicjc

454 

455 

456def test_path_param_lt_gt_4(): 1abcd

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

458 assert response.status_code == 422 2kclcmcnc

459 assert response.json() == { 2kclcmcnc

460 "detail": [ 

461 { 

462 "type": "less_than", 

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

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

465 "input": "4", 

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

467 } 

468 ] 

469 } 

470 

471 

472def test_path_param_lt_gt_0(): 1abcd

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

474 assert response.status_code == 422 2ocpcqcrc

475 assert response.json() == { 2ocpcqcrc

476 "detail": [ 

477 { 

478 "type": "greater_than", 

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

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

481 "input": "0", 

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

483 } 

484 ] 

485 } 

486 

487 

488def test_path_param_le_ge_2(): 1abcd

489 response = client.get("/path/param-le-ge/2") 2sctcucvc

490 assert response.status_code == 200 2sctcucvc

491 assert response.json() == 2 2sctcucvc

492 

493 

494def test_path_param_le_ge_1(): 1abcd

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

496 assert response.status_code == 200 2HdIdJdKd

497 

498 

499def test_path_param_le_ge_3(): 1abcd

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

501 assert response.status_code == 200 2wcxcyczc

502 assert response.json() == 3 2wcxcyczc

503 

504 

505def test_path_param_le_ge_4(): 1abcd

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

507 assert response.status_code == 422 2AcBcCcDc

508 assert response.json() == { 2AcBcCcDc

509 "detail": [ 

510 { 

511 "type": "less_than_equal", 

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

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

514 "input": "4", 

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

516 } 

517 ] 

518 } 

519 

520 

521def test_path_param_lt_int_2(): 1abcd

522 response = client.get("/path/param-lt-int/2") 2EcFcGcHc

523 assert response.status_code == 200 2EcFcGcHc

524 assert response.json() == 2 2EcFcGcHc

525 

526 

527def test_path_param_lt_int_42(): 1abcd

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

529 assert response.status_code == 422 2IcJcKcLc

530 assert response.json() == { 2IcJcKcLc

531 "detail": [ 

532 { 

533 "type": "less_than", 

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

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

536 "input": "42", 

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

538 } 

539 ] 

540 } 

541 

542 

543def test_path_param_lt_int_2_7(): 1abcd

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

545 assert response.status_code == 422 2McNcOcPc

546 assert response.json() == { 2McNcOcPc

547 "detail": [ 

548 { 

549 "type": "int_parsing", 

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

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

552 "input": "2.7", 

553 } 

554 ] 

555 } 

556 

557 

558def test_path_param_gt_int_42(): 1abcd

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

560 assert response.status_code == 200 2QcRcScTc

561 assert response.json() == 42 2QcRcScTc

562 

563 

564def test_path_param_gt_int_2(): 1abcd

565 response = client.get("/path/param-gt-int/2") 2UcVcWcXc

566 assert response.status_code == 422 2UcVcWcXc

567 assert response.json() == { 2UcVcWcXc

568 "detail": [ 

569 { 

570 "type": "greater_than", 

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

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

573 "input": "2", 

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

575 } 

576 ] 

577 } 

578 

579 

580def test_path_param_gt_int_2_7(): 1abcd

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

582 assert response.status_code == 422 2YcZc0c1c

583 assert response.json() == { 2YcZc0c1c

584 "detail": [ 

585 { 

586 "type": "int_parsing", 

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

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

589 "input": "2.7", 

590 } 

591 ] 

592 } 

593 

594 

595def test_path_param_le_int_42(): 1abcd

596 response = client.get("/path/param-le-int/42") 22c3c4c5c

597 assert response.status_code == 422 22c3c4c5c

598 assert response.json() == { 22c3c4c5c

599 "detail": [ 

600 { 

601 "type": "less_than_equal", 

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

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

604 "input": "42", 

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

606 } 

607 ] 

608 } 

609 

610 

611def test_path_param_le_int_3(): 1abcd

612 response = client.get("/path/param-le-int/3") 26c7c8c9c

613 assert response.status_code == 200 26c7c8c9c

614 assert response.json() == 3 26c7c8c9c

615 

616 

617def test_path_param_le_int_2(): 1abcd

618 response = client.get("/path/param-le-int/2") 2!c#c$c%c

619 assert response.status_code == 200 2!c#c$c%c

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

621 

622 

623def test_path_param_le_int_2_7(): 1abcd

624 response = client.get("/path/param-le-int/2.7") 2'c(c)c*c

625 assert response.status_code == 422 2'c(c)c*c

626 assert response.json() == { 2'c(c)c*c

627 "detail": [ 

628 { 

629 "type": "int_parsing", 

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

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

632 "input": "2.7", 

633 } 

634 ] 

635 } 

636 

637 

638def test_path_param_ge_int_42(): 1abcd

639 response = client.get("/path/param-ge-int/42") 2+c,c-c.c

640 assert response.status_code == 200 2+c,c-c.c

641 assert response.json() == 42 2+c,c-c.c

642 

643 

644def test_path_param_ge_int_3(): 1abcd

645 response = client.get("/path/param-ge-int/3") 2/c:c;c=c

646 assert response.status_code == 200 2/c:c;c=c

647 assert response.json() == 3 2/c:c;c=c

648 

649 

650def test_path_param_ge_int_2(): 1abcd

651 response = client.get("/path/param-ge-int/2") 2?c@c[c]c

652 assert response.status_code == 422 2?c@c[c]c

653 assert response.json() == { 2?c@c[c]c

654 "detail": [ 

655 { 

656 "type": "greater_than_equal", 

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

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

659 "input": "2", 

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

661 } 

662 ] 

663 } 

664 

665 

666def test_path_param_ge_int_2_7(): 1abcd

667 response = client.get("/path/param-ge-int/2.7") 2^c_c`c{c

668 assert response.status_code == 422 2^c_c`c{c

669 assert response.json() == { 2^c_c`c{c

670 "detail": [ 

671 { 

672 "type": "int_parsing", 

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

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

675 "input": "2.7", 

676 } 

677 ] 

678 } 

679 

680 

681def test_path_param_lt_gt_int_2(): 1abcd

682 response = client.get("/path/param-lt-gt-int/2") 2|c}c~cad

683 assert response.status_code == 200 2|c}c~cad

684 assert response.json() == 2 2|c}c~cad

685 

686 

687def test_path_param_lt_gt_int_4(): 1abcd

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

689 assert response.status_code == 422 2bdcddded

690 assert response.json() == { 2bdcddded

691 "detail": [ 

692 { 

693 "type": "less_than", 

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

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

696 "input": "4", 

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

698 } 

699 ] 

700 } 

701 

702 

703def test_path_param_lt_gt_int_0(): 1abcd

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

705 assert response.status_code == 422 2fdgdhdid

706 assert response.json() == { 2fdgdhdid

707 "detail": [ 

708 { 

709 "type": "greater_than", 

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

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

712 "input": "0", 

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

714 } 

715 ] 

716 } 

717 

718 

719def test_path_param_lt_gt_int_2_7(): 1abcd

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

721 assert response.status_code == 422 2jdkdldmd

722 assert response.json() == { 2jdkdldmd

723 "detail": [ 

724 { 

725 "type": "int_parsing", 

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

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

728 "input": "2.7", 

729 } 

730 ] 

731 } 

732 

733 

734def test_path_param_le_ge_int_2(): 1abcd

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

736 assert response.status_code == 200 2ndodpdqd

737 assert response.json() == 2 2ndodpdqd

738 

739 

740def test_path_param_le_ge_int_1(): 1abcd

741 response = client.get("/path/param-le-ge-int/1") 2rdsdtdud

742 assert response.status_code == 200 2rdsdtdud

743 assert response.json() == 1 2rdsdtdud

744 

745 

746def test_path_param_le_ge_int_3(): 1abcd

747 response = client.get("/path/param-le-ge-int/3") 2vdwdxdyd

748 assert response.status_code == 200 2vdwdxdyd

749 assert response.json() == 3 2vdwdxdyd

750 

751 

752def test_path_param_le_ge_int_4(): 1abcd

753 response = client.get("/path/param-le-ge-int/4") 2zdAdBdCd

754 assert response.status_code == 422 2zdAdBdCd

755 assert response.json() == { 2zdAdBdCd

756 "detail": [ 

757 { 

758 "type": "less_than_equal", 

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

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

761 "input": "4", 

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

763 } 

764 ] 

765 } 

766 

767 

768def test_path_param_le_ge_int_2_7(): 1abcd

769 response = client.get("/path/param-le-ge-int/2.7") 2DdEdFdGd

770 assert response.status_code == 422 2DdEdFdGd

771 assert response.json() == { 2DdEdFdGd

772 "detail": [ 

773 { 

774 "type": "int_parsing", 

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

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

777 "input": "2.7", 

778 } 

779 ] 

780 }