|
@@ -5,10 +5,10 @@ import requests
|
|
|
url = 'http://localhost:8080'
|
|
|
|
|
|
|
|
|
-def send_request(image_path):
|
|
|
+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': '0'})
|
|
|
+ r = requests.post(f'{url}/ocr_system/idcard', json={'image': img_str, 'image_type': image_type})
|
|
|
return r.json()
|
|
|
|
|
|
|
|
@@ -18,13 +18,21 @@ class TestIdCardOcr(unittest.TestCase):
|
|
|
|
|
|
def test_front_180(self):
|
|
|
image_path = './images/front-180.png'
|
|
|
- r = send_request(image_path)
|
|
|
+ r = send_request(image_path, '0')
|
|
|
self.assertEqual(r['status'], '000', 'status case error')
|
|
|
self.assertEqual(r['result']['orientation'], 2, 'orientation case error')
|
|
|
|
|
|
def test_front_270(self):
|
|
|
image_path = './images/front-270.png'
|
|
|
- r = send_request(image_path)
|
|
|
+ r = send_request(image_path, '0')
|
|
|
self.assertEqual(r['status'], '000', 'status case error')
|
|
|
self.assertEqual(r['result']['orientation'], 3, 'orientation case error')
|
|
|
|
|
|
+ def test_long_exp(self):
|
|
|
+ image_path = './images/long-exp.png'
|
|
|
+ r = send_request(image_path, '1')
|
|
|
+ self.assertEqual(r['status'], '000', 'status case error')
|
|
|
+ self.assertEqual(r['result']['expire_date']['text'], '20180227-长期', 'expire date case error')
|
|
|
+
|
|
|
+
|
|
|
+
|