Skip to content

Commit

Permalink
Merge pull request #154 from getyoti/release_2_10_1
Browse files Browse the repository at this point in the history
Release 2.10.1
  • Loading branch information
emmas-yoti authored Feb 21, 2020
2 parents 06f5278 + a022515 commit 9d2d1fe
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 25 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
omit =
yoti_python_sdk/tests/**
yoti_python_sdk/protobuf/**/*
examples/**
24 changes: 18 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ language: python

dist: xenial

# Only clone the most recent commit.
git:
depth: 1
depth: false

jobs:
allow_failures:
- python: "3.8-dev"
include:
- &test
stage: Test
Expand Down Expand Up @@ -49,7 +50,18 @@ jobs:
if: type = pull_request OR branch = master
after_success:
- coveralls

matrix:
allow_failures:
- python: "3.8-dev"
- stage: Analyze
name: Sonarcloud
dist: trusty
python: "3.6.1"
addons:
sonarcloud:
organization: "getyoti"
install:
- pip install -r requirements.txt
- pip install -e .[dev]
script:
- pytest --cov=yoti_python_sdk yoti_python_sdk/tests --cov-report=xml:coverage-reports/coverage-new.xml
- sed -i 's+<source>.*</source>+<source>/home/travis/build/getyoti/yoti-python-sdk/yoti_python_sdk</source>+g' coverage-reports/coverage-new.xml
- sonar-scanner
if: type = pull_request OR branch = master
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ itsdangerous==0.24
pbr==1.10.0
protobuf==3.7.0
pyopenssl==18.0.0
PyYAML==5.2 # PyYAML 5.3 does not support Python 3.4
pytz==2018.9
requests>=2.20.0
urllib3>=1.24.2
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ protobuf==3.7.0
pycparser==2.18 # via cffi
pyopenssl==18.0.0
pytz==2018.9
pyyaml==5.2
requests==2.21.0
six==1.10.0 # via cryptography, protobuf, pyopenssl
urllib3==1.24.2
wheel==0.24.0
wrapt==1.11.2 # via deprecated

# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.4.0 # via protobuf
# setuptools==43.0.0 # via protobuf
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"pylint==1.9.4",
"pylint-exit>=1.1.0",
"python-coveralls==2.9.3",
"coverage==4.5.4",
"mock==2.0.0",
"virtualenv==15.2",
],
Expand Down
12 changes: 7 additions & 5 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
sonar.projectKey = yoti-web-sdk:python
sonar.projectName = python-sdk
sonar.projectVersion = 2.10.0
sonar.exclusions=yoti_python_sdk/tests/**,examples/**
sonar.host.url = https://sonarcloud.io
sonar.organization = getyoti
sonar.projectKey = getyoti:python
sonar.projectName = Python SDK
sonar.projectVersion = 2.10.1
sonar.exclusions = yoti_python_sdk/tests/**,examples/**,yoti_python_sdk/protobuf/**/*

sonar.python.pylint.reportPath=coverage.out
sonar.python.pylint.reportPath = coverage.out
sonar.verbose = true
15 changes: 3 additions & 12 deletions yoti_python_sdk/document_details.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# -*- coding: utf-8 -*-
import re

from . import date_parser


class DocumentDetails(object):
VALIDATION_REGEX = re.compile("^[A-Za-z_]* [A-Za-z]{3} [A-Za-z0-9]{1}.*$")

def __init__(self, data):
self.__validate_data(data)
self.__parse_data(data)

@property
Expand All @@ -31,14 +26,10 @@ def expiration_date(self):
def issuing_authority(self):
return self.__dict__.get("_DocumentDetails__issuing_authority", None)

def __validate_data(self, data):
if self.VALIDATION_REGEX.search(data):
return
else:
raise ValueError("Invalid value for DocumentDetails")

def __parse_data(self, data):
data = data.split()
data = data.split(" ")
if len(data) < 3 or "" in data:
raise ValueError("Invalid value for DocumentDetails")

self.__document_type = data[0]
self.__issuing_country = data[1]
Expand Down
42 changes: 42 additions & 0 deletions yoti_python_sdk/tests/test_document_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,40 @@ def test_parse_3_words():
assert document.issuing_authority is None


def test_parse_redacted_aadhaar():
DATA = "AADHAAR IND ****1234"

document = DocumentDetails(DATA)

assert document.document_type == "AADHAAR"
assert document.issuing_country == "IND"
assert document.document_number == "****1234"
assert document.expiration_date is None
assert document.issuing_authority is None


@pytest.mark.parametrize(
"details, expected_number",
[
("type country **** - authority", "****"),
(
"type country ~!@#$%^&*()-_=+[]{}|;':,./<>? - authority",
"~!@#$%^&*()-_=+[]{}|;':,./<>?",
),
('type country "" - authority', '""'),
("type country \\ - authority", "\\"),
('type country " - authority', '"'),
("type country '' - authority", "''"),
("type country ' - authority", "'"),
],
)
def test_parse_special_characters(details, expected_number):
document = DocumentDetails(details)

assert document.document_type == "type"
assert document.document_number == expected_number


def test_parse_4_words():
DATA = "DRIVING_LICENCE GBR 1234abc 2016-05-01"

Expand Down Expand Up @@ -88,3 +122,11 @@ def test_invalid_date():
with pytest.raises(ValueError) as exc:
DocumentDetails(DATA)
assert str(exc.value) == "Invalid value for DocumentDetails"


def test_should_fail_with_double_space():
DATA = "AADHAAR IND ****1234"

with pytest.raises(ValueError) as exc:
DocumentDetails(DATA)
assert str(exc.value) == "Invalid value for DocumentDetails"
2 changes: 1 addition & 1 deletion yoti_python_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = "2.10.0"
__version__ = "2.10.1"

0 comments on commit 9d2d1fe

Please sign in to comment.