Skip to content

Commit 9d4baa3

Browse files
committed
SDK-303: Restructured ageVerified test
1 parent c64045c commit 9d4baa3

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

yoti_python_sdk/activity_details.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ def try_parse_selfie_field(self, field):
4040
)
4141

4242
def try_parse_age_verified_field(self, field):
43-
is_age_verified = Protobuf().value_based_on_content_type(
44-
field.value,
45-
field.content_type
46-
)
47-
if is_age_verified == 'true':
48-
self.user_profile['is_age_verified'] = True
49-
return
50-
if is_age_verified == 'false':
51-
self.user_profile['is_age_verified'] = False
52-
return
53-
else:
54-
raise TypeError("age_verified_field unable to be parsed")
43+
if field is not None:
44+
is_age_verified = Protobuf().value_based_on_content_type(
45+
field.value,
46+
field.content_type
47+
)
48+
if is_age_verified == 'true':
49+
self.user_profile['is_age_verified'] = True
50+
return
51+
if is_age_verified == 'false':
52+
self.user_profile['is_age_verified'] = False
53+
return
54+
55+
raise TypeError("age_verified_field unable to be parsed")
5556

5657
def try_convert_structured_postal_address_to_dict(self, field):
5758
decoder = json.JSONDecoder(object_pairs_hook=collections.OrderedDict)

yoti_python_sdk/protobuf/v1/protobuf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def value_based_on_content_type(self, value, content_type=None):
4040
return value.decode('utf-8')
4141
elif content_type == self.CT_DATE:
4242
return value.decode('utf-8')
43-
# elif content_type == self.CT_JSON:
44-
# return value.decode('utf-8')
4543
return value
4644

4745
def image_uri_based_on_content_type(self, value, content_type=None):

yoti_python_sdk/tests/test_activity_details.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ def test_try_parse_selfie_field_valid_selfie():
9797

9898
def test_try_parse_age_verified_both_missing_returns_null():
9999
activity_details = ActivityDetails(successful_receipt())
100-
create_selfie_field(activity_details)
100+
field = None
101101

102-
ActivityDetails.try_parse_age_verified_field(activity_details, activity_details.field)
103-
assert not activity_details.user_profile
102+
with pytest.raises(TypeError):
103+
ActivityDetails.try_parse_age_verified_field(activity_details, field)
104104

105105

106106
def test_try_parse_age_verified_field_age_over():

0 commit comments

Comments
 (0)