Zhang Li 2 лет назад
Родитель
Сommit
44d971dcdd
1 измененных файлов с 22 добавлено и 34 удалено
  1. 22 34
      testing/all_test.py

+ 22 - 34
testing/all_test.py

@@ -5,7 +5,7 @@ from pathlib import Path
 
 import requests
 
-url = 'http://192.168.199.107:18088'
+url = 'http://192.168.199.249:18081'
 
 
 def send_request(image_path, image_type):
@@ -167,43 +167,31 @@ class TestIdCard0(unittest.TestCase):
 
 
 
-class TestIdCard1(unittest.TestCase):
-    def _helper1(self, image_path, sta, orient, date):
-        root = Path(__file__).parent
-        image_path = str(root / image_path)
-        r = send_request(image_path, '1')
-        self.assertEqual(sta, r['status'], f'{image_path}status case error')
-        self.assertEqual(orient, r['result']['orientation'], f'{image_path} address case error')
-        self.assertEqual(date, r['result']['expire_date']['text'], f'{image_path} expire_date case error')
-
-
-    def test_01_0(self):
-        image_path = '../images/all/1/ 01_0.jpg'
-        self._helper1(image_path, '000', 0, '20220511-20410511')
-
-    def test_02_0(self):
-        image_path = '../images/all/1/ 02_0.jpg'
-        self._helper1(image_path, '000', 0, '20180531-20280531')
+import pytest
 
-    def test_03_180(self):
-        image_path = '../images/all/1/03_180.jpg'
-        self._helper1(image_path, '000', 2, '20170109-20270109')
+@pytest.mark.parametrize(
+    "image_path, status, orientation, expire_date",
+    [
+        ('../images/all/1/ 01_0.jpg', '000', 0, '20220511-20410511'),
+        # ('../images/all/1/ 02_0.jpg', '000', 0, '20180531-20280531'),
+        # ('../images/all/1/03_180.jpg', '000', 2, '20170109-20270109'),
+        # ('../images/all/1/04_90.jpg', '000', 1, '20190715-20390715'),
+        # ('../images/all/1/05-270.jpg', '000', 0, '20140320-20240320'),
+        # ('../images/all/1/small.png', '000', 0, '20190620-20290620'),
+        # ('../images/all/1/special.jpg', '000', 0, '20190813-20290813'),
+    ]
+)
+def test_back_side(image_path, status, orientation, expire_date):
+    root = Path(__file__).parent
+    image_path = str(root / image_path)
+    r = send_request(image_path, '1')
+    if r['status'] == '000':
+        assert (r['result']['expire_date']['text'], r['result']['orientation']) == (expire_date, orientation)
+    else:
+        assert r['status'] == status
 
-    def test_04_90(self):
-        image_path = '../images/all/1/04_90.jpg'
-        self._helper1(image_path, '000', 1, '20190715-20390715')
 
-    def test_05_270(self):
-        image_path = '../images/all/1/05-270.jpg'
-        self._helper1(image_path, '000', 0, '20140320-20240320')
-
-    def test_small(self):
-        image_path = '../images/all/1/small.png'
-        self._helper1(image_path, '000', 0, '20190620-20290620')
 
-    def test_special(self):
-        image_path = '../images/all/1/special.jpg'
-        self._helper1(image_path, '000', 0, '20190813-20290813')
 
 
 if __name__ == '__main__':