table_test.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import unittest
  2. import base64
  3. import requests
  4. from pathlib import Path
  5. url = 'http://192.168.199.107:18099'
  6. def send_request(image_path):
  7. with open(image_path, 'rb') as f:
  8. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  9. r = requests.post(f'{url}/ocr_system/table', json={'image': img_str, 'det': 'conv'})
  10. print(r.json())
  11. return r.json()
  12. class TestTableOcr(unittest.TestCase):
  13. # def test_it_work(self):
  14. # pong = requests.request("GET", '/'.join([url, 'ping']))
  15. # self.assertEqual('"pong!"', pong.text, 'Not work')
  16. def test_table_01(self):
  17. print("被旋转的图片")
  18. fn = Path(__file__).parent / '../images/01.jpeg'
  19. res = send_request(fn)
  20. # self.assertEqual('000', res['status'], 'Not work')
  21. #
  22. # def test_table_02(self):
  23. # res = send_request('./images/02.jpg')
  24. # self.assertEqual('000', res['status'], 'Not work')
  25. #
  26. # def test_table_03(self):
  27. # res = send_request('./images/03.jpg')
  28. # self.assertEqual('000', res['status'], 'Not work')
  29. #
  30. # def test_table_04(self):
  31. # res = send_request('./images/04.jpg')
  32. # self.assertEqual('000', res['status'], 'Not work')
  33. #
  34. # def test_table_05(self):
  35. # res = send_request('./images/05.jpeg')
  36. # self.assertEqual('000', res['status'], 'Not work')
  37. #
  38. # def test_table_06(self):
  39. # res = send_request('./images/06.jpeg')
  40. # self.assertEqual('000', res['status'], 'Not work')
  41. #
  42. # def test_table_07(self):
  43. # res = send_request('./images/07.jpeg')
  44. # self.assertEqual('000', res['status'], 'Not work')
  45. #
  46. # def test_table_08(self):
  47. # res = send_request('./images/08.jpg')
  48. # self.assertEqual('000', res['status'], 'Not work')
  49. if __name__ == '__main__':
  50. unittest.main()