Skip to content

Commit be993ee

Browse files
authored
add consistent read test (#310)
1 parent 96ff1f3 commit be993ee

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pynamodb/tests/test_model.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,33 @@ def test_batch_get(self):
23712371
}
23722372
self.assertEqual(params, req.call_args[0][1])
23732373

2374+
with patch(PATCH_METHOD) as req:
2375+
req.return_value = SIMPLE_BATCH_GET_ITEMS
2376+
item_keys = ['hash-{0}'.format(x) for x in range(10)]
2377+
for item in SimpleUserModel.batch_get(item_keys, consistent_read=True):
2378+
self.assertIsNotNone(item)
2379+
params = {
2380+
'ReturnConsumedCapacity': 'TOTAL',
2381+
'RequestItems': {
2382+
'SimpleModel': {
2383+
'Keys': [
2384+
{'user_name': {'S': 'hash-9'}},
2385+
{'user_name': {'S': 'hash-8'}},
2386+
{'user_name': {'S': 'hash-7'}},
2387+
{'user_name': {'S': 'hash-6'}},
2388+
{'user_name': {'S': 'hash-5'}},
2389+
{'user_name': {'S': 'hash-4'}},
2390+
{'user_name': {'S': 'hash-3'}},
2391+
{'user_name': {'S': 'hash-2'}},
2392+
{'user_name': {'S': 'hash-1'}},
2393+
{'user_name': {'S': 'hash-0'}}
2394+
],
2395+
'ConsistentRead': True
2396+
}
2397+
}
2398+
}
2399+
self.assertEqual(params, req.call_args[0][1])
2400+
23742401
with patch(PATCH_METHOD) as req:
23752402
req.return_value = MODEL_TABLE_DATA
23762403
UserModel('foo', 'bar')

0 commit comments

Comments
 (0)