number_test.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import base64
  2. import unittest
  3. from pathlib import Path
  4. import requests
  5. from testing.utils import *
  6. class TestBankCardOcr(unittest.TestCase):
  7. def _helper(self, image_path, card_no):
  8. root = Path(__file__).parent
  9. image_path = str(root / image_path)
  10. r = send_request(image_path)
  11. self.assertEqual(card_no, r['result']['number']['text'], f'{image_path} number case error')
  12. def test_error_01(self):
  13. image_path = '../images/error/num_error/01.png'
  14. self._helper(image_path, '6222033006002202085')
  15. def test_error_02(self):
  16. image_path = '../images/error/num_error/02.png'
  17. self._helper(image_path, '6212261507003221119')
  18. def test_error_03(self):
  19. image_path = '../images/error/num_error/03.png'
  20. self._helper(image_path, '6212261602022776043')
  21. # def test_error_06(self):
  22. # image_path = '../images/error/num_error/06.jpg'
  23. # self._helper(image_path, '6259760610567202')
  24. def test_error_07(self):
  25. image_path = '../images/error/num_error/07.png'
  26. self._helper(image_path, '6217858400038218235')
  27. def test_error_09(self):
  28. image_path = '../images/error/num_error/09.png'
  29. self._helper(image_path, '6214834725430715')
  30. def test_error_10(self):
  31. image_path = '../images/error/num_error/10.png'
  32. self._helper(image_path, '6221807010000715896')