test_interface.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. '''
  2. Author: zeke-chin zeke-chin@icloud.com
  3. Date: 2022-09-28 20:28:41
  4. LastEditors: zeke-chin zeke-chin@icloud.com
  5. LastEditTime: 2022-09-30 10:06:35
  6. FilePath: /to_md/HR_OCR/TestAllOcr/test_interface.py
  7. Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. '''
  9. from pathlib import Path
  10. import unittest
  11. import config
  12. from config import send_request
  13. image_path = 'image'
  14. # DX_test, DX_sb, DX_test, DX_sb
  15. envl = 'TX_sb'
  16. url = config.URL[envl]
  17. token = config.TOKEN[envl]
  18. class TestOcr(unittest.TestCase):
  19. def _helper(self, image_path, suffix):
  20. root = Path(__file__).parent
  21. image_path = str(root / image_path)
  22. r = send_request(image_path, suffix, url, token)
  23. print(r)
  24. self.assertIn('result', r, f'{suffix} test error')
  25. def test_bank(self):
  26. image_path = 'image/bankcard.jpg'
  27. suffix = '/yhksb/bankcard' if 'sb' in envl else '/yhksbtest/bankcard'
  28. self._helper(image_path, suffix)
  29. def test_idcard(self):
  30. image_path = 'image/idcard.jpg'
  31. suffix = '/sfzsb/idcard' if 'sb' in envl else '/sfzsbtest/idcard'
  32. self._helper(image_path, suffix)
  33. def test_regbook(self):
  34. image_path = 'image/regbook.jpg'
  35. suffix = '/hkbsb/regbook' if 'sb' in envl else '/hkbsbtest/regbook'
  36. self._helper(image_path, suffix)
  37. def test_schoolcert(self):
  38. image_path = 'image/schoolcert.jpg'
  39. suffix = '/xxw/schoolcert' if 'sb' in envl else '/xxwtest/schoolcert'
  40. self._helper(image_path, suffix)
  41. def test_cet(self):
  42. image_path = 'image/cet.jpg'
  43. suffix = '/cet/cet' if 'sb' in envl else '/cettest/cet'
  44. self._helper(image_path, suffix)
  45. def test_blef(self):
  46. image_path = 'image/blfe.jpg'
  47. suffix = '/blfe/blfe' if 'sb' in envl else '/blfetest/blfe'
  48. self._helper(image_path, suffix)