test_layout.py 646 B

123456789101112131415161718192021222324
  1. import unittest
  2. import requests
  3. url = 'http://localhost:8080/detect'
  4. def send_request(image_path):
  5. b_img_list = []
  6. f = open(image_path, "rb")
  7. b_img_list.append(('file_list', ('01'+'.jpg', f, 'images/jpg')))
  8. payload = {'model_name': 'ocr-layout', 'img_size': 1824, 'download_image': False}
  9. r = requests.post(f'{url}', headers={}, data=payload, files=b_img_list)
  10. print(r.json())
  11. return r.json()
  12. class TestLayout(unittest.TestCase):
  13. def test_01(self):
  14. r = send_request('../images/01.jpg')
  15. self.assertEqual(r['status'], '000', 'status case error')
  16. if __name__ == '__main__':
  17. unittest.main()