update expression attribute test

This commit is contained in:
Chris Keogh 2017-09-22 15:50:08 +12:00
parent 87d7cacda6
commit d0f38407a1
2 changed files with 13 additions and 6 deletions

View File

@ -412,8 +412,8 @@ class Table(BaseModel):
return None
def query(self, hash_key, range_comparison, range_objs, limit,
exclusive_start_key, scan_index_forward, projection_expression, index_name=None, **filter_kwargs):
exclusive_start_key, scan_index_forward, projection_expression,
index_name=None, **filter_kwargs):
results = []
if index_name:
all_indexes = (self.global_indexes or []) + (self.indexes or [])

View File

@ -390,24 +390,31 @@ def test_basic_projection_expressions_with_attr_expression_names():
table.put_item(Item={
'forum_name': 'the-key',
'subject': '123',
'body': 'some test message'
'body': 'some test message',
'attachment': 'something'
})
table.put_item(Item={
'forum_name': 'not-the-key',
'subject': '123',
'body': 'some other test message'
'body': 'some other test message',
'attachment': 'something'
})
# Test a query returning all items
results = table.query(
KeyConditionExpression=Key('forum_name').eq(
'the-key'),
ProjectionExpression='#rl, subject',
ExpressionAttributeNames={'#rl':'body'},
ProjectionExpression='#rl, #rt, subject',
ExpressionAttributeNames={
'#rl': 'body',
'#rt': 'attachment'
},
)
assert 'body' in results['Items'][0]
assert results['Items'][0]['body'] == 'some test message'
assert 'subject' in results['Items'][0]
assert results['Items'][0]['subject'] == '123'
assert 'attachment' in results['Items'][0]
assert results['Items'][0]['attachment'] == 'something'