test_bank.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. from pathlib import Path
  2. import pytest
  3. from testing.utils import send_request
  4. def helper(image_path, sta, orient, card_no):
  5. root = Path(__file__).parent
  6. image_path = str(root / image_path)
  7. r = send_request(image_path)
  8. assert sta, r['status']
  9. assert orient, r['result']['orientation']
  10. assert card_no, r['result']['number']['text']
  11. def get_from_request(image_path):
  12. root = Path(__file__).parent
  13. image_path = str(root / image_path)
  14. r = send_request(image_path)
  15. if r['status'] == '000':
  16. return r['status'], r['result']['orientation'], r['result']['number']['text']
  17. return '101', 0, ''
  18. @pytest.mark.convex
  19. @pytest.mark.parametrize(
  20. "p, status, t, no",
  21. [
  22. ('../images/all/convex/back_mess.jpg', '000', 0, '6222521510000593'),
  23. ('../images/all/convex/convex_0.jpg', '000', 0, '6258091767775765'),
  24. ('../images/all/convex/back_mess.jpg', '000', 0, '6222521510000593'),
  25. ('../images/all/convex/convex_0.jpg', '000', 0, '6258091767775765'),
  26. ('../images/all/convex/convex_0.jpg', '000', 1, '6217991910056756013'),
  27. ('../images/all/convex/convex_180.jpg', '000', 2, '6214835715794218'),
  28. ('../images/all/convex/convex_270.jpg', '000', 3, '6222081211001840619'),
  29. ('../images/all/convex/mohu1.jpg', '000', 0, '6212261602020022770'),
  30. ('../images/all/convex/mohu2.jpg', '000', 1, '6215581504002751986'),
  31. ('../images/all/convex/small.jpg', '000', 0, '6217981910002853676'),
  32. ('../images/all/convex/tilt1.jpg', '000', 3, '6215590613003222324'),
  33. ('../images/all/convex/tilt2.jpg', '000', 0, '623061571509189093'),
  34. ]
  35. )
  36. def test_convex(p, status, t, no):
  37. assert get_from_request(p) == (status, t, no)
  38. def test_01():
  39. image_path = '../images/all/convex/back_mess.jpg'
  40. assert get_from_request(image_path) == ('000', 0, '6222521510000593')
  41. def test_02():
  42. image_path = '../images/all/convex/convex_0.jpg'
  43. assert get_from_request(image_path) == ('000', 0, '6258091767775765')
  44. @pytest.mark.print
  45. @pytest.mark.parametrize(
  46. "p, status, t, no",
  47. [
  48. ('../images/all/print/front_0.jpg', '000', 0, '6216638405000213022'),
  49. ('../images/all/print/front_90.jpg', '000', 1, '6216618401001365345'),
  50. ('../images/all/print/front_180.png', '000', 2, '6230522590019175070'),
  51. ('../images/all/print/front_270.png', '000', 3, '6228480329658828572'),
  52. ('../images/all/print/long.jpg', '000', 0, '6217991910038919747'),
  53. ('../images/all/print/mohu1.jpg', '000', 1, '6217000416004100998'),
  54. ('../images/all/print/mohu2.jpg', '000', 0, '6217000870003035904'),
  55. ('../images/all/print/small1.jpg', '000', 0, '6222020602005624997'),
  56. ('../images/all/print/small2.png', '000', 0, '6222020602015798211'),
  57. ('../images/all/print/special.jpg', '000', 0, '6259760610567202'),
  58. ('../images/all/print/small2.png', '000', 0, '6222020602015798211'),
  59. ]
  60. )
  61. def test_print(p, status, t, no):
  62. assert get_from_request(p) == (status, t, no)