|
1 |
| -import binascii |
2 |
| -import io |
3 |
| -from os.path import abspath, dirname, join |
4 |
| - |
5 |
| -from yoti_python_sdk import anchor |
6 |
| -from yoti_python_sdk.protobuf import protobuf |
7 |
| - |
8 |
| -FIXTURES_DIR = join(dirname(abspath(__file__)), 'fixtures') |
9 |
| -ANCHOR_DRIVING_LICENSE = join(FIXTURES_DIR, 'anchor_driving_license.txt') |
10 |
| -ANCHOR_PASSPORT = join(FIXTURES_DIR, 'anchor_passport.txt') |
11 |
| -ANCHOR_YOTI_ADMIN = join(FIXTURES_DIR, 'anchor_yoti_admin.txt') |
12 |
| - |
13 |
| - |
14 |
| -def get_anchor_from_base64_text(file_path): |
15 |
| - base64_driving_license_anchor = read_file(file_path) |
16 |
| - driving_license_anchor_bytes = binascii.a2b_base64(base64_driving_license_anchor) |
17 |
| - |
18 |
| - protobuf_anchor = protobuf.Protobuf().anchor(driving_license_anchor_bytes) |
19 |
| - anchors = list() |
20 |
| - anchors.append(protobuf_anchor) |
21 |
| - |
22 |
| - return anchors |
23 |
| - |
24 |
| - |
25 |
| -def get_parsed_driving_license_anchor(): |
26 |
| - return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_DRIVING_LICENSE))[0] |
27 |
| - |
28 |
| - |
29 |
| -def get_parsed_passport_anchor(): |
30 |
| - return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_PASSPORT))[0] |
31 |
| - |
32 |
| - |
33 |
| -def get_parsed_yoti_admin_anchor(): |
34 |
| - return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_YOTI_ADMIN))[0] |
35 |
| - |
36 |
| - |
37 |
| -def read_file(file_path): |
38 |
| - with io.open(file_path, mode='r', encoding='utf-8') as file: |
39 |
| - return file.read() |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from os.path import abspath, dirname, join |
| 3 | + |
| 4 | +from yoti_python_sdk import anchor |
| 5 | +from yoti_python_sdk.protobuf import protobuf |
| 6 | +from yoti_python_sdk.tests import file_helper |
| 7 | + |
| 8 | +FIXTURES_DIR = join(dirname(abspath(__file__)), 'fixtures') |
| 9 | +ANCHOR_DRIVING_LICENSE = join(FIXTURES_DIR, 'anchor_driving_license.txt') |
| 10 | +ANCHOR_PASSPORT = join(FIXTURES_DIR, 'anchor_passport.txt') |
| 11 | +ANCHOR_YOTI_ADMIN = join(FIXTURES_DIR, 'anchor_yoti_admin.txt') |
| 12 | + |
| 13 | + |
| 14 | +def get_anchor_from_base64_text(file_path): |
| 15 | + anchor_bytes = file_helper.get_file_bytes(file_path) |
| 16 | + |
| 17 | + protobuf_anchor = protobuf.Protobuf().anchor(anchor_bytes) |
| 18 | + anchors = list() |
| 19 | + anchors.append(protobuf_anchor) |
| 20 | + |
| 21 | + return anchors |
| 22 | + |
| 23 | + |
| 24 | +def get_parsed_driving_license_anchor(): |
| 25 | + return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_DRIVING_LICENSE))[0] |
| 26 | + |
| 27 | + |
| 28 | +def get_parsed_passport_anchor(): |
| 29 | + return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_PASSPORT))[0] |
| 30 | + |
| 31 | + |
| 32 | +def get_parsed_yoti_admin_anchor(): |
| 33 | + return anchor.Anchor().parse_anchors(get_anchor_from_base64_text(ANCHOR_YOTI_ADMIN))[0] |
0 commit comments