Skip to content

Commit

Permalink
add BOOL into SHORT_ATTR_TYPES (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
yedpodtrzitko authored and danielhochman committed Nov 7, 2016
1 parent aa395b6 commit ae06940
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ doc/
.project
.DS_Store
.idea
*.egg-info

# Ignore auto-save files
[#]*[#]
Expand Down
2 changes: 1 addition & 1 deletion pynamodb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
MAP = 'Map'
LIST = 'List'
SHORT_ATTR_TYPES = [STRING_SHORT, STRING_SET_SHORT, NUMBER_SHORT, NUMBER_SET_SHORT,
BINARY_SHORT, BINARY_SET_SHORT, MAP_SHORT, LIST_SHORT]
BINARY_SHORT, BINARY_SET_SHORT, MAP_SHORT, LIST_SHORT, BOOLEAN_SHORT]
ATTR_TYPE_MAP = {
STRING: STRING_SHORT,
STRING_SET: STRING_SET_SHORT,
Expand Down
25 changes: 25 additions & 0 deletions pynamodb/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Meta:
custom_aliases = UnicodeSetAttribute(attr_name='aliases')
icons = BinarySetAttribute()
views = NumberAttribute(null=True)
is_active = BooleanAttribute(null=True)


class ThrottledUserModel(Model):
Expand Down Expand Up @@ -1100,6 +1101,30 @@ def test_update_item(self):
}
deep_eq(args, params, _assert=True)

with patch(PATCH_METHOD) as req:
item.update_item('is_active', True, action='put')
args = req.call_args[0][1]
params = {
'TableName': 'SimpleModel',
'ReturnValues': 'ALL_NEW',
'Key': {
'user_name': {
'S': 'foo'
}
},
'AttributeUpdates': {
'is_active': {
'Action': 'PUT',
'Value': {
'BOOL': True
}
}
},
'ReturnConsumedCapacity': 'TOTAL'
}
deep_eq(args, params, _assert=True)


def test_save(self):
"""
Model.save
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
exclude = .tox,docs,build

[tox]
envlist = py26,py27,py33,py34,pypy
envlist = py26,py27,py33,py34,py35,pypy

[testenv]
deps = -rrequirements.txt
commands = nosetests
commands = nosetests

0 comments on commit ae06940

Please sign in to comment.