Skip to content

Commit 7bb64e8

Browse files
committed
SDK-868: Change try block to be whole attribute parsing, don't return None. Revert setup.py
1 parent dbe7697 commit 7bb64e8

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
'Operating System :: OS Independent',
3131
'Intended Audience :: Developers',
3232
'Programming Language :: Python',
33+
'Programming Language :: Python :: 2',
34+
'Programming Language :: Python :: 2.6',
35+
'Programming Language :: Python :: 2.7',
3336
'Programming Language :: Python :: 3',
3437
'Programming Language :: Python :: 3.3',
3538
'Programming Language :: Python :: 3.4',

yoti_python_sdk/profile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def __init__(self, profile_attributes):
2020
field.value,
2121
field.content_type
2222
)
23-
except Exception as exc:
24-
error = 'Error parsing profile attribute: "{0}"'.format(field.name)
25-
logging.warning('error: {0}, exception: {1} - {2}'.format(error, type(exc).__name__, exc))
26-
value = None
2723

28-
anchors = Anchor().parse_anchors(field.anchors)
24+
anchors = Anchor().parse_anchors(field.anchors)
25+
26+
self.attributes[field.name] = Attribute(field.name, value, anchors)
2927

30-
self.attributes[field.name] = Attribute(field.name, value, anchors)
28+
if field.name == config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS:
29+
self.try_convert_structured_postal_address_to_dict(field, anchors)
3130

32-
if field.name == config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS:
33-
self.try_convert_structured_postal_address_to_dict(field, anchors)
31+
except Exception as exc:
32+
error = 'Error parsing profile attribute: "{0}"'.format(field.name)
33+
logging.warning('error: {0}, exception: {1} - {2}'.format(error, type(exc).__name__, exc))
3434

3535
self.ensure_postal_address()
3636

yoti_python_sdk/tests/test_profile.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ def test_error_parsing_attribute_has_none_value():
124124

125125
profile = Profile(attribute_list)
126126

127-
retrieved_string_attribute = profile.get_attribute(int_attribute_name)
128-
assert retrieved_string_attribute.name == int_attribute_name
129-
assert retrieved_string_attribute.value is None
127+
assert profile.get_attribute(int_attribute_name) is None
130128

131129

132130
def test_error_parsing_attribute_does_not_affect_other_attribute():
@@ -150,7 +148,7 @@ def test_error_parsing_attribute_does_not_affect_other_attribute():
150148

151149
profile = Profile(attribute_list)
152150

153-
assert len(profile.attributes) == 2
151+
assert len(profile.attributes) == 1
154152

155153
retrieved_string_attribute = profile.get_attribute(string_attribute_name)
156154
assert retrieved_string_attribute.name == string_attribute_name

0 commit comments

Comments
 (0)