Merge pull request #711 from skygeo/fix_dynamodb2_conditions
fix: dynamodb2 conditions
This commit is contained in:
commit
f7ea66c248
2 changed files with 40 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ from freezegun import freeze_time
|
|||
from boto.exception import JSONResponseError
|
||||
from moto import mock_dynamodb2
|
||||
from tests.helpers import requires_boto_gte
|
||||
import botocore
|
||||
try:
|
||||
from boto.dynamodb2.fields import HashKey
|
||||
from boto.dynamodb2.table import Table
|
||||
|
|
@ -469,6 +470,7 @@ def test_update_item_set():
|
|||
})
|
||||
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_failed_overwrite():
|
||||
table = Table.create('messages', schema=[
|
||||
|
|
@ -585,6 +587,37 @@ def test_boto3_conditions():
|
|||
response['Items'][0].should.equal({"username": "johndoe"})
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_boto3_put_item_conditions_fails():
|
||||
table = _create_user_table()
|
||||
table.put_item(Item={'username': 'johndoe', 'foo': 'bar'})
|
||||
table.put_item.when.called_with(
|
||||
Item={'username': 'johndoe', 'foo': 'baz'},
|
||||
Expected={
|
||||
'foo': {
|
||||
'ComparisonOperator': 'NE',
|
||||
'AttributeValueList': ['bar']
|
||||
}
|
||||
}).should.throw(botocore.client.ClientError)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_boto3_put_item_conditions_pass():
|
||||
table = _create_user_table()
|
||||
table.put_item(Item={'username': 'johndoe', 'foo': 'bar'})
|
||||
table.put_item(
|
||||
Item={'username': 'johndoe', 'foo': 'baz'},
|
||||
Expected={
|
||||
'foo': {
|
||||
'ComparisonOperator': 'EQ',
|
||||
'AttributeValueList': ['bar']
|
||||
}
|
||||
})
|
||||
returned_item = table.get_item(Key={'username': 'johndoe'})
|
||||
assert dict(returned_item)['Item']['foo'].should.equal("baz")
|
||||
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_scan_pagination():
|
||||
table = _create_user_table()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue