test_interface.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from pathlib import Path
  2. import unittest
  3. import config
  4. from config import send_request
  5. image_path = 'image'
  6. # DX_test, DX_sb, DX_test, DX_sb
  7. envl = 'DX_test'
  8. url = config.URL[envl]
  9. token = config.TOKEN[envl]
  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. print(r)
  16. self.assertIn('result', r, f'{suffix} test error')
  17. def test_bank(self):
  18. image_path = 'image/bankcard.jpg'
  19. suffix = '/yhksb/bankcard' if 'sb' in envl else '/yhksbtest/bankcard'
  20. self._helper(image_path, suffix)
  21. def test_idcard(self):
  22. image_path = 'image/idcard.jpg'
  23. suffix = '/sfzsb/idcard' if 'sb' in envl else '/sfzsbtest/idcard'
  24. self._helper(image_path, suffix)
  25. def test_regbook(self):
  26. image_path = 'image/regbook.jpg'
  27. suffix = '/hkbsb/regbook' if 'sb' in envl else '/hkbsbtest/regbook'
  28. self._helper(image_path, suffix)
  29. def test_schoolcert(self):
  30. image_path = 'image/schoolcert.jpg'
  31. suffix = '/xxw/schoolcert' if 'sb' in envl else '/xxwtest/schoolcert'
  32. self._helper(image_path, suffix)
  33. def test_cet(self):
  34. image_path = 'image/cet.jpg'
  35. suffix = '/cet/cet' if 'sb' in envl else '/cettest/cet'
  36. self._helper(image_path, suffix)
  37. def test_blef(self):
  38. image_path = 'image/blfe.jpg'
  39. suffix = '/blfe/blfe' if 'sb' in envl else '/blfetest/blfe'
  40. self._helper(image_path, suffix)