test_interface.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # TX_test, TX_sb, DX_test, DX_sb
  8. envl = 'DX_test'
  9. url = config.URL[envl]
  10. token = config.TOKEN[envl]
  11. # 生产集群
  12. class TestOcr(unittest.TestCase):
  13. def _helper(self, image_path, suffix):
  14. root = Path(__file__).parent
  15. image_path = str(root / image_path)
  16. r = send_request(image_path, suffix, url, token)
  17. self.assertIn('result', r, f'{suffix} test error')
  18. def test_bank(self):
  19. image_path = './image/bankcard.jpg'
  20. suffix = '/yhksb/bankcard' if 'sb' in envl else '/yhksbtest/bankcard'
  21. print(suffix)
  22. self._helper(image_path, suffix)
  23. def test_idcard(self):
  24. image_path = './image/idcard.jpg'
  25. suffix = '/sfzsb/idcard' if 'sb' in envl else '/sfzsbtest/idcard'
  26. self._helper(image_path, suffix)
  27. def test_regbook(self):
  28. image_path = './image/regbook.jpg'
  29. suffix = '/hkbsb/regbook' if 'sb' in envl else '/hkbsbtest/regbook'
  30. self._helper(image_path, suffix)
  31. def test_schoolcert(self):
  32. image_path = './image/schoolcert.jpg'
  33. suffix = '/xxw/schoolcert' if 'sb' in envl else '/xxwtest/schoolcert'
  34. self._helper(image_path, suffix)
  35. def test_cet(self):
  36. image_path = './image/cet.jpg'
  37. suffix = '/cet/cet' if 'sb' in envl else '/cettest/cet'
  38. self._helper(image_path, suffix)
  39. def test_blef(self):
  40. image_path = './image/blfe.jpg'
  41. suffix = '/blfe/blfe' if 'sb' in envl else '/blfetest/blfe'
  42. self._helper(image_path, suffix)