from pathlib import Path import pytest from testing.utils import send_request def helper(image_path, sta, orient, card_no): root = Path(__file__).parent image_path = str(root / image_path) r = send_request(image_path) assert sta, r['status'] assert orient, r['result']['orientation'] assert card_no, r['result']['number']['text'] def get_from_request(image_path): root = Path(__file__).parent image_path = str(root / image_path) r = send_request(image_path) if r['status'] == '000': return r['status'], r['result']['orientation'], r['result']['number']['text'] return '101', 0, '' @pytest.mark.convex @pytest.mark.parametrize( "p, status, t, no", [ ('../images/all/convex/back_mess.jpg', '000', 0, '6222521510000593'), ('../images/all/convex/convex_0.jpg', '000', 0, '6258091767775765'), ('../images/all/convex/back_mess.jpg', '000', 0, '6222521510000593'), ('../images/all/convex/convex_0.jpg', '000', 0, '6258091767775765'), ('../images/all/convex/convex_0.jpg', '000', 1, '6217991910056756013'), ('../images/all/convex/convex_180.jpg', '000', 2, '6214835715794218'), ('../images/all/convex/convex_270.jpg', '000', 3, '6222081211001840619'), ('../images/all/convex/mohu1.jpg', '000', 0, '6212261602020022770'), ('../images/all/convex/mohu2.jpg', '000', 1, '6215581504002751986'), ('../images/all/convex/small.jpg', '000', 0, '6217981910002853676'), ('../images/all/convex/tilt1.jpg', '000', 3, '6215590613003222324'), ('../images/all/convex/tilt2.jpg', '000', 0, '623061571509189093'), ] ) def test_convex(p, status, t, no): assert get_from_request(p) == (status, t, no) def test_01(): image_path = '../images/all/convex/back_mess.jpg' assert get_from_request(image_path) == ('000', 0, '6222521510000593') def test_02(): image_path = '../images/all/convex/convex_0.jpg' assert get_from_request(image_path) == ('000', 0, '6258091767775765') @pytest.mark.print @pytest.mark.parametrize( "p, status, t, no", [ ('../images/all/print/front_0.jpg', '000', 0, '6216638405000213022'), ('../images/all/print/front_90.jpg', '000', 1, '6216618401001365345'), ('../images/all/print/front_180.png', '000', 2, '6230522590019175070'), ('../images/all/print/front_270.png', '000', 3, '6228480329658828572'), ('../images/all/print/long.jpg', '000', 0, '6217991910038919747'), ('../images/all/print/mohu1.jpg', '000', 1, '6217000416004100998'), ('../images/all/print/mohu2.jpg', '000', 0, '6217000870003035904'), ('../images/all/print/small1.jpg', '000', 0, '6222020602005624997'), ('../images/all/print/small2.png', '000', 0, '6222020602015798211'), ('../images/all/print/special.jpg', '000', 0, '6259760610567202'), ('../images/all/print/small2.png', '000', 0, '6222020602015798211'), ] ) def test_print(p, status, t, no): assert get_from_request(p) == (status, t, no)