test_interface.py 2.5 KB

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