test_interface.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # DX_test, DX_sb, DX_test, DX_sb
  8. envl = 'DX_sb'
  9. url = config.URL[envl]
  10. token = config.TOKEN[envl]
  11. # 生产集群
  12. class TestSbOcr(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'
  21. self._helper(image_path, suffix)
  22. def test_idcard(self):
  23. image_path = './image/idcard.jpg'
  24. suffix = '/sfzsb/idcard'
  25. self._helper(image_path, suffix)
  26. def test_regbook(self):
  27. image_path = './image/regbook.jpg'
  28. suffix = '/hkbsb/regbook'
  29. self._helper(image_path, suffix)
  30. def test_schoolcert(self):
  31. image_path = './image/schoolcert.jpg'
  32. suffix = '/xxw/schoolcert'
  33. self._helper(image_path, suffix)
  34. def test_cet(self):
  35. image_path = './image/cet.jpg'
  36. suffix = '/cet/cet'
  37. self._helper(image_path, suffix)
  38. def test_blef(self):
  39. image_path = './image/blfe.jpg'
  40. suffix = '/blfe/blfe'
  41. self._helper(image_path, suffix)
  42. # 测试集群
  43. class TestOcr(unittest.TestCase):
  44. def _helper(self, image_path, suffix):
  45. root = Path(__file__).parent
  46. image_path = str(root / image_path)
  47. r = send_request(image_path, suffix, url, token)
  48. self.assertIn('result', r, f'{suffix} test error')
  49. def test_bank(self):
  50. image_path = './image/bankcard.jpg'
  51. suffix = '/yhksbtest/bankcard'
  52. self._helper(image_path, suffix)
  53. def test_idcard(self):
  54. image_path = './image/idcard.jpg'
  55. suffix = '/sfzsbtest/idcard'
  56. self._helper(image_path, suffix)
  57. def test_regbook(self):
  58. image_path = './image/regbook.jpg'
  59. suffix = '/hkbsbtest/regbook'
  60. self._helper(image_path, suffix)
  61. def test_schoolcert(self):
  62. image_path = './image/schoolcert.jpg'
  63. suffix = '/xxwtest/schoolcert'
  64. self._helper(image_path, suffix)
  65. def test_cet(self):
  66. image_path = './image/cet.jpg'
  67. suffix = '/cettest/cet'
  68. self._helper(image_path, suffix)
  69. def test_blef(self):
  70. image_path = './image/blfe.jpg'
  71. suffix = '/blfetest/blfe'
  72. self._helper(image_path, suffix)