Skip to content

Commit 4d0bef2

Browse files
committed
SDK-508: Change is_age_verified to be age_verified
1 parent 435f0ea commit 4d0bef2

File tree

8 files changed

+44
-46
lines changed

8 files changed

+44
-46
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ family_name = profile.family_name.value
127127
full_name = profile.full_name.value
128128
phone_number = profile.phone_number.value
129129
date_of_birth = profile.date_of_birth.value
130-
is_age_verified = profile.is_age_verified.value
130+
age_verified = profile.age_verified.value
131131
postal_address = profile.postal_address.value
132132
gender = profile.gender.value
133133
nationality = profile.nationality.value
@@ -273,6 +273,7 @@ For information on testing with multiple Python versions, see [VERSION-SUPPORT.m
273273

274274
* Activity Details
275275
* [X] User ID `user_id`
276+
* [X] User Profile `user_profile` - **deprecated**, use `profile` instead
276277
* [X] Profile `profile`
277278
* [X] Photo `selfie`
278279
* [X] Given Names `given_names`
@@ -281,7 +282,7 @@ For information on testing with multiple Python versions, see [VERSION-SUPPORT.m
281282
* [X] Mobile Number `phone_number`
282283
* [X] Email Address `email_address`
283284
* [X] Age / Date of Birth `date_of_birth`
284-
* [X] Age / Is Age Verified `is_age_verified`
285+
* [X] Age / Age Verified `age_verified`
285286
* [X] Address `postal_address`
286287
* [X] Gender `gender`
287288
* [X] Nationality `nationality`
@@ -305,4 +306,4 @@ If you're using Windows and you haven't installed Cryptography before, you might
305306
set LIB=C:\OpenSSL-Win64\lib;%LIB%
306307
set INCLUDE=C:\OpenSSL-Win64\include;%INCLUDE%
307308
```
308-
Where `OpenSSL-Win64` is the location that you have installed OpenSSL to. See [here](https://cryptography.io/en/latest/installation/#building-cryptography-on-windows) for more information.
309+
Where `OpenSSL-Win64` is the location that you have installed OpenSSL to. See [here](https://cryptography.io/en/latest/installation/#building-cryptography-on-windows) for more information.

examples/yoti_example_django/yoti_example/templates/profile.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,21 @@ <h3>Yoti Profile</h3>
212212
</td>
213213
</tr>
214214
{% endif %}
215-
{% if profile.is_age_verified is not None %}
215+
{% if profile.age_verified is not None %}
216216
<tr>
217217
<th scope="row">Age verified</th>
218-
<td>{{profile.is_age_verified.value }}</td>
218+
<td>{{profile.age_verified.value }}</td>
219219
<td colspan="3">
220220
<table class="table">
221221
<tbody>
222-
{% for source in profile.is_age_verified.sources %}
222+
{% for source in profile.age_verified.sources %}
223223
<tr class="row no-gutters">
224224
<td class="col-md-3">Source</td>
225225
<td class="col-md-6">{{ source.value }}</td>
226226
<td class="col-md-3">{{ source.sub_type }}</td>
227227
</tr>
228228
{% endfor %}
229-
{% for verifier in profile.is_age_verified.verifiers %}
229+
{% for verifier in profile.age_verified.verifiers %}
230230
<tr class="row no-gutters">
231231
<td class="col-md-3">Verifier</td>
232232
<td class="col-md-6">{{ verifier.value }}</td>

examples/yoti_example_flask/templates/profile.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,21 @@ <h3>Yoti Profile</h3>
212212
</td>
213213
</tr>
214214
{% endif %}
215-
{% if profile.is_age_verified is defined%}
215+
{% if profile.age_verified is defined%}
216216
<tr>
217217
<th scope="row">Age verified</th>
218-
<td>{{ profile.is_age_verified.value }}</td>
218+
<td>{{ profile.age_verified.value }}</td>
219219
<td colspan="3">
220220
<table class="table">
221221
<tbody>
222-
{% for source in profile.is_age_verified.sources %}
222+
{% for source in profile.age_verified.sources %}
223223
<tr class="row no-gutters">
224224
<td class="col-md-3">Source</td>
225225
<td class="col-md-6">{{ source.value }}</td>
226226
<td class="col-md-3">{{ source.sub_type }}</td>
227227
</tr>
228228
{% endfor %}
229-
{% for verifier in profile.is_age_verified.verifiers %}
229+
{% for verifier in profile.age_verified.verifiers %}
230230
<tr class="row no-gutters">
231231
<td class="col-md-3">Verifier</td>
232232
<td class="col-md-6">{{ verifier.value }}</td>

yoti_python_sdk/activity_details.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ def try_parse_selfie_field(self, field):
4848

4949
def try_parse_age_verified_field(self, field):
5050
if field is not None:
51-
is_age_verified = Protobuf().value_based_on_content_type(
51+
age_verified = Protobuf().value_based_on_content_type(
5252
field.value,
5353
field.content_type
5454
)
55-
if is_age_verified == 'true':
56-
self.user_profile[config.ATTRIBUTE_IS_AGE_VERIFIED] = True
55+
if age_verified == 'true':
56+
self.user_profile[config.ATTRIBUTE_AGE_VERIFIED] = True
5757
return
58-
if is_age_verified == 'false':
59-
self.user_profile[config.ATTRIBUTE_IS_AGE_VERIFIED] = False
58+
if age_verified == 'false':
59+
self.user_profile[config.ATTRIBUTE_AGE_VERIFIED] = False
6060
return
6161

62-
print("age_verified_field value: '{0}' was unable to be parsed into a boolean value".format(is_age_verified))
62+
print(
63+
"age_verified_field value: '{0}' was unable to be parsed into a boolean value".format(age_verified))
6364

6465
def try_convert_structured_postal_address_to_dict(self, field):
6566
decoder = json.JSONDecoder(object_pairs_hook=collections.OrderedDict, strict=False)

yoti_python_sdk/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ATTRIBUTE_FULL_NAME = "full_name"
99
ATTRIBUTE_GENDER = "gender"
1010
ATTRIBUTE_GIVEN_NAMES = "given_names"
11-
ATTRIBUTE_IS_AGE_VERIFIED = "is_age_verified"
11+
ATTRIBUTE_AGE_VERIFIED = "age_verified"
1212
ATTRIBUTE_NATIONALITY = "nationality"
1313
ATTRIBUTE_PHONE_NUMBER = "phone_number"
1414
ATTRIBUTE_POSTAL_ADDRESS = "postal_address"

yoti_python_sdk/profile.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def given_names(self):
5252
return self.get_attribute(config.ATTRIBUTE_GIVEN_NAMES)
5353

5454
@property
55-
def is_age_verified(self):
56-
return self.get_attribute(config.ATTRIBUTE_IS_AGE_VERIFIED)
55+
def age_verified(self):
56+
return self.get_attribute(config.ATTRIBUTE_AGE_VERIFIED)
5757

5858
@property
5959
def nationality(self):
@@ -83,18 +83,19 @@ def get_attribute(self, attribute_name):
8383

8484
def try_parse_age_verified_field(self, field, anchors):
8585
if field is not None:
86-
is_age_verified = Protobuf().value_based_on_content_type(
86+
age_verified = Protobuf().value_based_on_content_type(
8787
field.value,
8888
field.content_type
8989
)
90-
if is_age_verified == 'true':
91-
self.profile[config.ATTRIBUTE_IS_AGE_VERIFIED] = Attribute(is_age_verified, True, anchors)
90+
if age_verified == 'true':
91+
self.profile[config.ATTRIBUTE_AGE_VERIFIED] = Attribute(age_verified, True, anchors)
9292
return
93-
if is_age_verified == 'false':
94-
self.profile[config.ATTRIBUTE_IS_AGE_VERIFIED] = Attribute(is_age_verified, False, anchors)
93+
if age_verified == 'false':
94+
self.profile[config.ATTRIBUTE_AGE_VERIFIED] = Attribute(age_verified, False, anchors)
9595
return
9696

97-
raise TypeError("age_verified_field unable to be parsed")
97+
print(
98+
"age_verified_field value: '{0}' was unable to be parsed into a boolean value".format(age_verified))
9899

99100
def try_convert_structured_postal_address_to_dict(self, field, anchors):
100101
decoder = json.JSONDecoder(object_pairs_hook=collections.OrderedDict, strict=False)

yoti_python_sdk/tests/test_activity_details.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import collections
33
import json
44

5-
import pytest
6-
75
from yoti_python_sdk import config
86
from yoti_python_sdk.activity_details import ActivityDetails
97
from yoti_python_sdk.protobuf.v1.protobuf import Protobuf
@@ -99,31 +97,31 @@ def test_try_parse_age_verified_both_missing_not_parsed():
9997
field = None
10098

10199
ActivityDetails.try_parse_age_verified_field(activity_details, field)
102-
assert not isinstance(activity_details.user_profile.get(config.ATTRIBUTE_IS_AGE_VERIFIED), bool)
100+
assert not isinstance(activity_details.user_profile.get(config.ATTRIBUTE_AGE_VERIFIED), bool)
103101

104102

105103
def test_try_parse_age_verified_field_age_over():
106104
activity_details = ActivityDetails(successful_receipt())
107105
create_age_verified_field(activity_details, True, "true".encode(), 18)
108106

109107
ActivityDetails.try_parse_age_verified_field(activity_details, activity_details.field)
110-
assert activity_details.user_profile[config.ATTRIBUTE_IS_AGE_VERIFIED] is True
108+
assert activity_details.user_profile[config.ATTRIBUTE_AGE_VERIFIED] is True
111109

112110

113111
def test_try_parse_age_verified_field_age_under():
114112
activity_details = ActivityDetails(successful_receipt())
115113
create_age_verified_field(activity_details, False, "false".encode(), 55)
116114

117115
ActivityDetails.try_parse_age_verified_field(activity_details, activity_details.field)
118-
assert activity_details.user_profile[config.ATTRIBUTE_IS_AGE_VERIFIED] is False
116+
assert activity_details.user_profile[config.ATTRIBUTE_AGE_VERIFIED] is False
119117

120118

121119
def test_try_parse_age_verified_field_non_bool_value_not_parsed():
122120
activity_details = ActivityDetails(successful_receipt())
123121
create_age_verified_field(activity_details, True, "18".encode(), 18)
124122

125123
ActivityDetails.try_parse_age_verified_field(activity_details, activity_details.field)
126-
assert not isinstance(activity_details.user_profile.get(config.ATTRIBUTE_IS_AGE_VERIFIED), bool)
124+
assert not isinstance(activity_details.user_profile.get(config.ATTRIBUTE_AGE_VERIFIED), bool)
127125

128126

129127
def test_try_parse_structured_postal_address_uk():

yoti_python_sdk/tests/test_profile.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,23 @@ def test_try_parse_age_verified_field_age_over():
107107
create_attribute_list_with_age_verified_field(
108108
True, "true".encode(), 18))
109109

110-
assert profile.profile[config.ATTRIBUTE_IS_AGE_VERIFIED].value is True
110+
assert profile.age_verified.value is True
111111

112112

113113
def test_try_parse_age_verified_field_age_under():
114114
profile = Profile(
115115
create_attribute_list_with_age_verified_field(
116116
False, "false".encode(), 55))
117117

118-
assert profile.profile[config.ATTRIBUTE_IS_AGE_VERIFIED].value is False
118+
assert profile.age_verified.value is False
119119

120120

121-
def test_try_parse_age_verified_field_non_bool_value_throws_error():
122-
with pytest.raises(TypeError):
123-
Profile(create_attribute_list_with_age_verified_field(
121+
def test_try_parse_age_verified_field_non_bool_value_not_parsed():
122+
profile = Profile(create_attribute_list_with_age_verified_field(
124123
True, "18".encode(), 18))
125124

125+
assert not isinstance(profile.age_verified, bool)
126+
126127

127128
def test_try_parse_structured_postal_address_uk():
128129
structured_postal_address = {ADDRESS_FORMAT_KEY: ADDRESS_FORMAT_VALUE,
@@ -138,8 +139,7 @@ def test_try_parse_structured_postal_address_uk():
138139

139140
profile = Profile(create_attribute_list_with_structured_postal_address_field(structured_postal_address_json))
140141

141-
actual_structured_postal_address_profile = profile.profile[
142-
config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value
142+
actual_structured_postal_address_profile = profile.structured_postal_address.value
143143

144144
assert type(actual_structured_postal_address_profile) is collections.OrderedDict
145145
assert actual_structured_postal_address_profile[ADDRESS_FORMAT_KEY] == ADDRESS_FORMAT_VALUE
@@ -171,8 +171,7 @@ def test_try_parse_structured_postal_address_india():
171171

172172
profile = Profile(create_attribute_list_with_structured_postal_address_field(structured_postal_address_bytes))
173173

174-
actual_structured_postal_address_profile = profile.profile[
175-
config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value
174+
actual_structured_postal_address_profile = profile.structured_postal_address.value
176175

177176
assert type(actual_structured_postal_address_profile) is collections.OrderedDict
178177
assert actual_structured_postal_address_profile[ADDRESS_FORMAT_KEY] == INDIA_FORMAT_VALUE
@@ -204,8 +203,7 @@ def test_try_parse_structured_postal_address_usa():
204203

205204
profile = Profile(create_attribute_list_with_structured_postal_address_field(structured_postal_address_bytes))
206205

207-
actual_structured_postal_address_profile = profile.profile[
208-
config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value
206+
actual_structured_postal_address_profile = profile.structured_postal_address.value
209207

210208
assert type(actual_structured_postal_address_profile) is collections.OrderedDict
211209
assert actual_structured_postal_address_profile[ADDRESS_FORMAT_KEY] == USA_FORMAT_VALUE
@@ -243,8 +241,7 @@ def test_try_parse_structured_postal_address_nested_json():
243241

244242
profile = Profile(create_attribute_list_with_structured_postal_address_field(structured_postal_address_bytes))
245243

246-
actual_structured_postal_address_profile = profile.profile[
247-
config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value
244+
actual_structured_postal_address_profile = profile.structured_postal_address.value
248245

249246
assert type(actual_structured_postal_address_profile) is collections.OrderedDict
250247
assert actual_structured_postal_address_profile[ADDRESS_FORMAT_KEY] == ADDRESS_FORMAT_VALUE
@@ -264,7 +261,7 @@ def test_set_address_to_be_formatted_address():
264261

265262
profile = Profile(create_attribute_list_with_structured_postal_address_field(structured_postal_address_bytes))
266263

267-
assert profile.profile[config.ATTRIBUTE_POSTAL_ADDRESS].value == FORMATTED_ADDRESS_VALUE
264+
assert profile.postal_address.value == FORMATTED_ADDRESS_VALUE
268265

269266

270267
def test_get_attribute():

0 commit comments

Comments
 (0)