12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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/paddle', json={'images': [img_str],'img_type':'text'})
- print(r.json())
- return r.json()
- class TestpaddleOcr(unittest.TestCase):
- def test_it_work(self):
- pong = requests.request("GET", '/'.join([url, 'ping']))
- self.assertEqual('"pong!"', pong.text, 'Not work')
- def test_paddle_01(self):
- print("被旋转的图片")
- res = send_request('./images/01.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_02(self):
- res = send_request('./images/02.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_03(self):
- res = send_request('./images/03.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_04(self):
- res = send_request('./images/04.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_05(self):
- res = send_request('./images/05.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_06(self):
- res = send_request('./images/06.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_07(self):
- res = send_request('./images/07.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_paddle_08(self):
- res = send_request('./images/08.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- if __name__ == '__main__':
- unittest.main()
|