yan chuanli 2 years ago
parent
commit
818ac9f847
2 changed files with 61 additions and 33 deletions
  1. 22 22
      TestAllOcr/config.py
  2. 39 11
      TestAllOcr/test_interface.py

+ 22 - 22
TestAllOcr/config.py

@@ -2,42 +2,42 @@ import base64
 import requests
 
 # 测试url
-test_url = 'http://aihub-test.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
-sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
-idc_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
-blfe_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
+TX_test_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
+TX_sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
+DX_test_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
+DX_sb_url = 'http://aihub-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
 
 URL = {
-    'test': test_url,
-    'sb': sb_url,
-    'idc': idc_url,
-    'blfe': blfe_url
+    'TX_test': TX_test_url,
+    'TX_sb': TX_sb_url,
+    'DX_test': DX_test_url,
+    'DX_sb': DX_sb_url
+}
+
+DX = {
+
 }
 
 # 测试token
-test_header = {
-    'Content-Type': 'application/json',
-    'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
+TX_test = {
+    'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'
 }
-sb_header = {
-    'Content-Type': 'application/json',
+TX_sb = {
     'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'
 }
-idc_header = {
-    'Content-Type': 'application/json',
+DX_test = {
     'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
 }
 
-blfe_header = {
-    'Content-Type': 'application/json',
-    'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'
+DX_sb = {
+    'Authorization': 'Bearer e045de0a-e97f-4f23-b4d5-6a032c39a81e'
 }
 
 TOKEN = {
-    'test': test_header,
-    'sb': sb_header,
-    'idc': idc_header,
-    'blfe': blfe_header
+    'TX_test': TX_test,
+    'TX_sb': TX_sb,
+    'DX_test': DX_test,
+    'DX_sb': DX_sb
 }
 
 def send_request(image_path, suffix, URL, TOKEN):

+ 39 - 11
TestAllOcr/test_interface.py

@@ -1,17 +1,17 @@
 import base64
 from pathlib import Path
 import unittest
-import requests
 import config
 from config import send_request
 
 image_path = 'image'
 
-# test, sb ,idc
-url = config.URL['sb']
-token = config.TOKEN['sb']
+# DX_test, DX_sb, DX_test, DX_sb
+url = config.URL['DX_sb']
+token = config.TOKEN['DX_sb']
 
-class TestOcr(unittest.TestCase):
+# 生产集群
+class TestSbOcr(unittest.TestCase):
 
     def _helper(self, image_path, suffix):
         root = Path(__file__).parent
@@ -44,18 +44,46 @@ class TestOcr(unittest.TestCase):
         suffix = '/cet/cet'
         self._helper(image_path, suffix)
 
+    def test_blef(self):
+        image_path = './image/blfe.jpg'
+        suffix = '/blfe/blfe'
+        self._helper(image_path, suffix)
+
+# 测试集群
+class TestOcr(unittest.TestCase):
 
-# 测试营业执照
-URL = config.URL['blfe']
-token1 = config.TOKEN['blfe']
-class TestBlfeOcr(unittest.TestCase):
     def _helper(self, image_path, suffix):
         root = Path(__file__).parent
         image_path = str(root / image_path)
-        r = send_request(image_path, suffix, URL, token)
+        r = send_request(image_path, suffix, url, token)
         self.assertIn('result', r, f'{suffix} test error')
 
-    def test_blfe(self):
+    def test_bank(self):
+        image_path = './image/bankcard.jpg'
+        suffix = '/yhksbtest/bankcard'
+        self._helper(image_path, suffix)
+
+    def test_idcard(self):
+        image_path = './image/idcard.jpg'
+        suffix = '/sfzsbtest/idcard'
+        self._helper(image_path, suffix)
+
+    def test_regbook(self):
+        image_path = './image/regbook.jpg'
+        suffix = '/hkbsbtest/regbook'
+        self._helper(image_path, suffix)
+
+    def test_schoolcert(self):
+        image_path = './image/schoolcert.jpg'
+        suffix = '/xxwtest/schoolcert'
+        self._helper(image_path, suffix)
+
+    def test_cet(self):
+        image_path = './image/cet.jpg'
+        suffix = '/cettest/cet'
+        self._helper(image_path, suffix)
+
+    def test_blef(self):
         image_path = './image/blfe.jpg'
         suffix = '/blfetest/blfe'
         self._helper(image_path, suffix)