-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use attr.get_value(value) when deserialize #450
Use attr.get_value(value) when deserialize #450
Conversation
can you add some tests? |
assert True == LBAModel.get('pkey1').flag | ||
assert False == LBAModel.get('pkey2').flag | ||
assert None == LBAModel.get('pkey3').flag | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change, update_item will throw TypeError: expected string or buffer
assert True == LBAModel.get('pkey1').flag | ||
assert False == LBAModel.get('pkey2').flag | ||
assert None == LBAModel.get('pkey3').flag | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change, update will throw TypeError: expected string or buffer
|
||
|
||
@pytest.mark.ddblocal | ||
def test_legacy_boolean_attribute_deserialization_compatibility(ddb_url): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably pytest.mark.parametrize those two tests
+1 |
assert None == BAModel.get('pkey3').flag | ||
|
||
# Update a value in the model causing BooleanAttribute to be deserialized | ||
BAModel.get('pkey1').update(actions=[BAModel.value.set('value2')]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to perform this set of updates on top of fresh LBAModel saves, instead of after update_item calls? technically update_item could correct the issue for the item, and the update calls would succeed even without the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Change update & update_item to use attr.get_value(value) in deserialization.
The PR #149 introduced
attr.get_value(value)
for backward compatibility between LBA and BA, and used it inmodel.from_raw_data
but not inmodel.update_item
(normodel.update
) causing code like https://gist.github.com/betamoo/1fb15692d6fa74b9ddacfd4965632b26 to fail