table_test.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. payload = {'image': img_str, 'det': 'conv'}
  10. print(payload)
  11. r = requests.post(f'{url}/ocr_system/table', json=payload)
  12. print(r.json())
  13. return r.json()
  14. class TestTableOcr(unittest.TestCase):
  15. # def test_it_work(self):
  16. # pong = requests.request("GET", '/'.join([url, 'ping']))
  17. # self.assertEqual('"pong!"', pong.text, 'Not work')
  18. # def test_table_01(self):
  19. # print("270")
  20. # fn = Path(__file__).parent / '../images/01.jpeg'
  21. # res = send_request(fn)
  22. # self.assertEqual('000', res['status'], 'Not work')
  23. def test_table_02(self):
  24. print("270")
  25. fn = Path(__file__).parent / '../images/02.jpg'
  26. res = send_request(fn)
  27. # self.assertEqual('000', res['status'], 'Not work')
  28. #
  29. # def test_table_03(self):
  30. # res = send_request('./images/03.jpg')
  31. # self.assertEqual('000', res['status'], 'Not work')
  32. #
  33. # def test_table_04(self):
  34. # res = send_request('./images/04.jpg')
  35. # self.assertEqual('000', res['status'], 'Not work')
  36. #
  37. # def test_table_05(self):
  38. # res = send_request('./images/05.jpeg')
  39. # self.assertEqual('000', res['status'], 'Not work')
  40. #
  41. # def test_table_06(self):
  42. # res = send_request('./images/06.jpeg')
  43. # self.assertEqual('000', res['status'], 'Not work')
  44. #
  45. # def test_table_07(self):
  46. # res = send_request('./images/07.jpeg')
  47. # self.assertEqual('000', res['status'], 'Not work')
  48. #
  49. # def test_table_08(self):
  50. # res = send_request('./images/08.jpg')
  51. # self.assertEqual('000', res['status'], 'Not work')
  52. if __name__ == '__main__':
  53. unittest.main()