1234567891011121314151617181920212223242526272829 |
- import unittest
- import base64
- import requests
- url = 'http://localhost:8080'
- def send_request(image_path):
- 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'})
- return r.json()
- class TestIdCardOcr(unittest.TestCase):
- def test_it_works(self):
- self.assertEqual(1, 1, 'it not works')
- def test_front_180(self):
- image_path = './images/front-180.png'
- r = send_request(image_path)
- self.assertEqual(r['status'], '000', 'status case error')
- self.assertEqual(r['result']['orientation'], 2, 'orientation case error')
- def test_front_90(self):
- image_path = './images/front-90.png'
- r = send_request(image_path)
- self.assertEqual(r['status'], '000', 'status case error')
- self.assertEqual(r['result']['orientation'], 1, 'orientation case error')
|