'''
Author: zeke-chin zeke-chin@icloud.com
Date: 2022-09-28 20:28:41
LastEditors: zeke-chin zeke-chin@icloud.com
LastEditTime: 2022-09-30 10:06:35
FilePath: /utils/HR_OCR/TestAllOcr/test_interface.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from pathlib import Path
import unittest
import config
from config import send_request

image_path = 'image'

# DX_test, DX_sb, DX_test, DX_sb
envl = 'TX_sb'
url = config.URL[envl]
token = config.TOKEN[envl]

class TestOcr(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)
        print(r)
        self.assertIn('result', r, f'{suffix} test error')

    def test_bank(self):
        image_path = 'image/bankcard.jpg'
        suffix = '/yhksb/bankcard' if 'sb' in envl else '/yhksbtest/bankcard'
        self._helper(image_path, suffix)

    def test_idcard(self):
        image_path = 'image/idcard.jpg'
        suffix = '/sfzsb/idcard' if 'sb' in envl else '/sfzsbtest/idcard'
        self._helper(image_path, suffix)

    def test_regbook(self):
        image_path = 'image/regbook.jpg'
        suffix = '/hkbsb/regbook' if 'sb' in envl else '/hkbsbtest/regbook'
        self._helper(image_path, suffix)

    def test_schoolcert(self):
        image_path = 'image/schoolcert.jpg'
        suffix = '/xxw/schoolcert' if 'sb' in envl else '/xxwtest/schoolcert'
        self._helper(image_path, suffix)

    def test_cet(self):
        image_path = 'image/cet.jpg'
        suffix = '/cet/cet' if 'sb' in envl else '/cettest/cet'
        self._helper(image_path, suffix)

    def test_blef(self):
        image_path = 'image/blfe.jpg'
        suffix = '/blfe/blfe' if 'sb' in envl else '/blfetest/blfe'
        self._helper(image_path, suffix)
