import base64 import unittest from pathlib import Path import requests from testing.utils import * class TestBankCardOcr(unittest.TestCase): def _helper(self, image_path, card_no): root = Path(__file__).parent image_path = str(root / image_path) r = send_request(image_path) self.assertEqual(card_no, r['result']['number']['text'], f'{image_path} number case error') def test_error_01(self): image_path = '../images/error/num_error/01.png' self._helper(image_path, '6222033006002202085') def test_error_02(self): image_path = '../images/error/num_error/02.png' self._helper(image_path, '6212261507003221119') def test_error_03(self): image_path = '../images/error/num_error/03.png' self._helper(image_path, '6212261602022776043') # def test_error_06(self): # image_path = '../images/error/num_error/06.jpg' # self._helper(image_path, '6259760610567202') def test_error_07(self): image_path = '../images/error/num_error/07.png' self._helper(image_path, '6217858400038218235') def test_error_09(self): image_path = '../images/error/num_error/09.png' self._helper(image_path, '6214834725430715') def test_error_10(self): image_path = '../images/error/num_error/10.png' self._helper(image_path, '6221807010000715896')