paddle_test.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import unittest
  2. import base64
  3. import requests
  4. url = 'http://localhost:8080'
  5. def send_request(image_path):
  6. with open(image_path, 'rb') as f:
  7. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  8. r = requests.post(f'{url}/ocr_system/paddle', json={'images': [img_str],'img_type':'text'})
  9. print(r.json())
  10. return r.json()
  11. class TestpaddleOcr(unittest.TestCase):
  12. def test_it_work(self):
  13. pong = requests.request("GET", '/'.join([url, 'ping']))
  14. self.assertEqual('"pong!"', pong.text, 'Not work')
  15. def test_paddle_01(self):
  16. print("被旋转的图片")
  17. res = send_request('./images/01.jpeg')
  18. self.assertEqual('000', res['status'], 'Not work')
  19. def test_paddle_02(self):
  20. res = send_request('./images/02.jpg')
  21. self.assertEqual('000', res['status'], 'Not work')
  22. def test_paddle_03(self):
  23. res = send_request('./images/03.jpg')
  24. self.assertEqual('000', res['status'], 'Not work')
  25. def test_paddle_04(self):
  26. res = send_request('./images/04.jpg')
  27. self.assertEqual('000', res['status'], 'Not work')
  28. def test_paddle_05(self):
  29. res = send_request('./images/05.jpeg')
  30. self.assertEqual('000', res['status'], 'Not work')
  31. def test_paddle_06(self):
  32. res = send_request('./images/06.jpeg')
  33. self.assertEqual('000', res['status'], 'Not work')
  34. def test_paddle_07(self):
  35. res = send_request('./images/07.jpeg')
  36. self.assertEqual('000', res['status'], 'Not work')
  37. def test_paddle_08(self):
  38. res = send_request('./images/08.jpg')
  39. self.assertEqual('000', res['status'], 'Not work')
  40. if __name__ == '__main__':
  41. unittest.main()