123456789101112131415161718192021222324252627282930313233 |
- import unittest
- import base64
- from pathlib import Path
- import requests
- url = 'http://192.168.199.208:18081'
- def send_request(image_path, image_type):
- with open(image_path, 'rb') as f:
- img_str: str = base64.encodebytes(f.read()).decode('utf-8')
- r = requests.post(f'{url}/ocr_system/idcard', json={'image': img_str, 'image_type': image_type})
- print(r.json())
- return r.json()
- class TestIdCardAddress(unittest.TestCase):
- def _helper(self, image_path, id):
- root = Path(__file__).parent
- image_path = str(root / image_path)
- r = send_request(image_path, '0')
- self.assertEqual(id, r['result']['id']['text'], f'{image_path} id case error')
- # def test_01(self):
- # image_path = '../images/false/miss_id/01.jpg'
- # self._helper(image_path, '52213019970701363X')
- if __name__ == '__main__':
- unittest.main()
|