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/table', json={'image': img_str})
- print(r.json())
- return r.json()
- class TestTableOcr(unittest.TestCase):
- def test_it_work(self):
- pong = requests.request("GET", '/'.join([url, 'ping']))
- self.assertEqual('"pong!"', pong.text, 'Not work')
- def test_table_01(self):
- print("被旋转的图片")
- res = send_request('./images/01.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_02(self):
- res = send_request('./images/02.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_03(self):
- res = send_request('./images/03.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_04(self):
- res = send_request('./images/04.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_05(self):
- res = send_request('./images/05.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_06(self):
- res = send_request('./images/06.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_07(self):
- res = send_request('./images/07.jpeg')
- self.assertEqual('000', res['status'], 'Not work')
- def test_table_08(self):
- res = send_request('./images/08.jpg')
- self.assertEqual('000', res['status'], 'Not work')
- if __name__ == '__main__':
- unittest.main()
|