orient_0_test.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import unittest
  2. import base64
  3. from pathlib import Path
  4. import requests
  5. from testing.utils import *
  6. class TestIdCardAddress(unittest.TestCase):
  7. def _helper(self, image_path, orient, image_type='0'):
  8. root = Path(__file__).parent
  9. image_path = str(root / image_path)
  10. r = send_request(image_path, image_type)
  11. self.assertEqual(orient, r['result']['orientation'], f'{image_path} orientation case error')
  12. def test_01_0(self):
  13. image_path = '../images/all/0/01_0.jpg'
  14. self._helper(image_path, 0)
  15. def test_01_90(self):
  16. image_path = '../images/all/0/01_90.jpg'
  17. self._helper(image_path, 1)
  18. def test_01_180(self):
  19. image_path = '../images/all/0/01_180.jpg'
  20. self._helper(image_path, 2)
  21. def test_01_270(self):
  22. image_path = '../images/all/0/01_270.jpg'
  23. self._helper(image_path, 3)
  24. def test_02_0(self):
  25. image_path = '../images/all/0/02.jpg'
  26. self._helper(image_path, 0)
  27. def test_05_0(self):
  28. image_path = '../images/all/0/05_0.jpg'
  29. self._helper(image_path, 0)
  30. def test_05_90(self):
  31. image_path = '../images/all/0/05_90.jpg'
  32. self._helper(image_path, 1)
  33. def test_05_180(self):
  34. image_path = '../images/all/0/05_180.jpg'
  35. self._helper(image_path, 2)
  36. def test_05_270(self):
  37. image_path = '../images/all/0/05_270.jpg'
  38. self._helper(image_path, 3)