test_interface.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. name = 'sb'
  9. url = config.URL[name]
  10. token = config.TOKEN[name]
  11. class TestOcr(unittest.TestCase):
  12. def _helper(self, image_path, suffix):
  13. root = Path(__file__).parent
  14. image_path = str(root / image_path)
  15. r = send_request(image_path, suffix, url, token)
  16. self.assertIn('result', r, f'{suffix} test error')
  17. def test_bank(self):
  18. image_path = './image/bankcard.jpg'
  19. suffix = '/yhksb/bankcard'
  20. self._helper(image_path, suffix)
  21. def test_idcard(self):
  22. image_path = './image/idcard.jpg'
  23. suffix = '/sfzsb/idcard'
  24. self._helper(image_path, suffix)
  25. def test_regbook(self):
  26. image_path = './image/regbook.jpg'
  27. suffix = '/hkbsb/regbook'
  28. self._helper(image_path, suffix)
  29. def test_schoolcert(self):
  30. image_path = './image/schoolcert.jpg'
  31. suffix = '/xxw/schoolcert'
  32. self._helper(image_path, suffix)
  33. def test_cet(self):
  34. image_path = './image/cet.jpg'
  35. suffix = '/cet/cet'
  36. self._helper(image_path, suffix)