other_test.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import base64
  2. import unittest
  3. from pathlib import Path
  4. import requests
  5. url = 'http://192.168.199.208:18081'
  6. def send_request(image_path, image_type):
  7. with open(image_path, 'rb') as f:
  8. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  9. r = requests.post(f'{url}/ocr_system/idcard', json={'image': img_str, 'image_type': image_type})
  10. print(r.json())
  11. return r.json()
  12. class TestIdCardAddress(unittest.TestCase):
  13. def _helper(self, image_path):
  14. root = Path(__file__).parent
  15. image_path = str(root / image_path)
  16. r = send_request(image_path, 0)
  17. self.assertEqual(r['status'], '000', f'{image_path}status case error')
  18. # 难
  19. def test_06(self):
  20. image_path = '../images/false/others/06.jpg'
  21. self._helper(image_path)
  22. # 难
  23. def test_07(self):
  24. image_path = '../images/false/others/07.jpg'
  25. self._helper(image_path)
  26. # 北京市宣武区cpca错误
  27. def test_cpca(self):
  28. image_path = '../images/false/others/cpca.png'
  29. self._helper(image_path)
  30. def test_long_name(self):
  31. image_path = '../images/false/others/long_name.png'
  32. self._helper(image_path)