test_interface.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import base64
  2. from pathlib import Path
  3. import unittest
  4. import config
  5. from config import send_request
  6. image_path = 'image'
  7. # test, sb ,idc
  8. url = config.URL['idc']
  9. token = config.TOKEN['idc']
  10. class TestOcr(unittest.TestCase):
  11. def _helper(self, image_path, suffix):
  12. root = Path(__file__).parent
  13. image_path = str(root / image_path)
  14. r = send_request(image_path, suffix, url, token)
  15. self.assertIn('result', r, f'{suffix} test error')
  16. def test_bank(self):
  17. image_path = './image/bankcard.jpg'
  18. suffix = '/yhksb/bankcard'
  19. self._helper(image_path, suffix)
  20. def test_idcard(self):
  21. image_path = './image/idcard.jpg'
  22. suffix = '/sfzsb/idcard'
  23. self._helper(image_path, suffix)
  24. def test_regbook(self):
  25. image_path = './image/regbook.jpg'
  26. suffix = '/hkbsb/regbook'
  27. self._helper(image_path, suffix)
  28. def test_schoolcert(self):
  29. image_path = './image/schoolcert.jpg'
  30. suffix = '/xxw/schoolcert'
  31. self._helper(image_path, suffix)
  32. def test_cet(self):
  33. image_path = './image/cet.jpg'
  34. suffix = '/cet/cet'
  35. self._helper(image_path, suffix)