Skip to content

Commit 9d2d1fe

Browse files
authored
Merge pull request #154 from getyoti/release_2_10_1
Release 2.10.1
2 parents 06f5278 + a022515 commit 9d2d1fe

File tree

9 files changed

+76
-25
lines changed

9 files changed

+76
-25
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[run]
22
omit =
33
yoti_python_sdk/tests/**
4+
yoti_python_sdk/protobuf/**/*
45
examples/**

.travis.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ language: python
22

33
dist: xenial
44

5-
# Only clone the most recent commit.
65
git:
7-
depth: 1
6+
depth: false
87

98
jobs:
9+
allow_failures:
10+
- python: "3.8-dev"
1011
include:
1112
- &test
1213
stage: Test
@@ -49,7 +50,18 @@ jobs:
4950
if: type = pull_request OR branch = master
5051
after_success:
5152
- coveralls
52-
53-
matrix:
54-
allow_failures:
55-
- python: "3.8-dev"
53+
- stage: Analyze
54+
name: Sonarcloud
55+
dist: trusty
56+
python: "3.6.1"
57+
addons:
58+
sonarcloud:
59+
organization: "getyoti"
60+
install:
61+
- pip install -r requirements.txt
62+
- pip install -e .[dev]
63+
script:
64+
- pytest --cov=yoti_python_sdk yoti_python_sdk/tests --cov-report=xml:coverage-reports/coverage-new.xml
65+
- sed -i 's+<source>.*</source>+<source>/home/travis/build/getyoti/yoti-python-sdk/yoti_python_sdk</source>+g' coverage-reports/coverage-new.xml
66+
- sonar-scanner
67+
if: type = pull_request OR branch = master

requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ itsdangerous==0.24
77
pbr==1.10.0
88
protobuf==3.7.0
99
pyopenssl==18.0.0
10+
PyYAML==5.2 # PyYAML 5.3 does not support Python 3.4
1011
pytz==2018.9
1112
requests>=2.20.0
1213
urllib3>=1.24.2

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ protobuf==3.7.0
2020
pycparser==2.18 # via cffi
2121
pyopenssl==18.0.0
2222
pytz==2018.9
23+
pyyaml==5.2
2324
requests==2.21.0
2425
six==1.10.0 # via cryptography, protobuf, pyopenssl
2526
urllib3==1.24.2
2627
wheel==0.24.0
2728
wrapt==1.11.2 # via deprecated
2829

2930
# The following packages are considered to be unsafe in a requirements file:
30-
# setuptools==41.4.0 # via protobuf
31+
# setuptools==43.0.0 # via protobuf

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"pylint==1.9.4",
4545
"pylint-exit>=1.1.0",
4646
"python-coveralls==2.9.3",
47+
"coverage==4.5.4",
4748
"mock==2.0.0",
4849
"virtualenv==15.2",
4950
],

sonar-project.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
sonar.projectKey = yoti-web-sdk:python
2-
sonar.projectName = python-sdk
3-
sonar.projectVersion = 2.10.0
4-
sonar.exclusions=yoti_python_sdk/tests/**,examples/**
1+
sonar.host.url = https://sonarcloud.io
2+
sonar.organization = getyoti
3+
sonar.projectKey = getyoti:python
4+
sonar.projectName = Python SDK
5+
sonar.projectVersion = 2.10.1
6+
sonar.exclusions = yoti_python_sdk/tests/**,examples/**,yoti_python_sdk/protobuf/**/*
57

6-
sonar.python.pylint.reportPath=coverage.out
8+
sonar.python.pylint.reportPath = coverage.out
79
sonar.verbose = true

yoti_python_sdk/document_details.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
import re
3-
42
from . import date_parser
53

64

75
class DocumentDetails(object):
8-
VALIDATION_REGEX = re.compile("^[A-Za-z_]* [A-Za-z]{3} [A-Za-z0-9]{1}.*$")
9-
106
def __init__(self, data):
11-
self.__validate_data(data)
127
self.__parse_data(data)
138

149
@property
@@ -31,14 +26,10 @@ def expiration_date(self):
3126
def issuing_authority(self):
3227
return self.__dict__.get("_DocumentDetails__issuing_authority", None)
3328

34-
def __validate_data(self, data):
35-
if self.VALIDATION_REGEX.search(data):
36-
return
37-
else:
38-
raise ValueError("Invalid value for DocumentDetails")
39-
4029
def __parse_data(self, data):
41-
data = data.split()
30+
data = data.split(" ")
31+
if len(data) < 3 or "" in data:
32+
raise ValueError("Invalid value for DocumentDetails")
4233

4334
self.__document_type = data[0]
4435
self.__issuing_country = data[1]

yoti_python_sdk/tests/test_document_details.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,40 @@ def test_parse_3_words():
3434
assert document.issuing_authority is None
3535

3636

37+
def test_parse_redacted_aadhaar():
38+
DATA = "AADHAAR IND ****1234"
39+
40+
document = DocumentDetails(DATA)
41+
42+
assert document.document_type == "AADHAAR"
43+
assert document.issuing_country == "IND"
44+
assert document.document_number == "****1234"
45+
assert document.expiration_date is None
46+
assert document.issuing_authority is None
47+
48+
49+
@pytest.mark.parametrize(
50+
"details, expected_number",
51+
[
52+
("type country **** - authority", "****"),
53+
(
54+
"type country ~!@#$%^&*()-_=+[]{}|;':,./<>? - authority",
55+
"~!@#$%^&*()-_=+[]{}|;':,./<>?",
56+
),
57+
('type country "" - authority', '""'),
58+
("type country \\ - authority", "\\"),
59+
('type country " - authority', '"'),
60+
("type country '' - authority", "''"),
61+
("type country ' - authority", "'"),
62+
],
63+
)
64+
def test_parse_special_characters(details, expected_number):
65+
document = DocumentDetails(details)
66+
67+
assert document.document_type == "type"
68+
assert document.document_number == expected_number
69+
70+
3771
def test_parse_4_words():
3872
DATA = "DRIVING_LICENCE GBR 1234abc 2016-05-01"
3973

@@ -88,3 +122,11 @@ def test_invalid_date():
88122
with pytest.raises(ValueError) as exc:
89123
DocumentDetails(DATA)
90124
assert str(exc.value) == "Invalid value for DocumentDetails"
125+
126+
127+
def test_should_fail_with_double_space():
128+
DATA = "AADHAAR IND ****1234"
129+
130+
with pytest.raises(ValueError) as exc:
131+
DocumentDetails(DATA)
132+
assert str(exc.value) == "Invalid value for DocumentDetails"

yoti_python_sdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "2.10.0"
2+
__version__ = "2.10.1"

0 commit comments

Comments
 (0)