DynamoDB ConditionalCheckFailedException到测试项目已经存在testacse

时间:2019-07-10 01:45:00

标签: python amazon-web-services amazon-dynamodb pytest

我想使用pytest中的ConditionalCheckFailedException测试ID是否已经存在。

   def does_id_exist(id, item):
    try:
       put_item(item=item,condition_expression=Attr('Id').not_exists())
    except    
       client_dynamodb().exceptions.ConditionalCheckFailedException as err:
       log_info('ConditionalCheckFailedException', err)
       return True
    return False

我正在尝试关注,但似乎不起作用。



def key_exist(client_dynamodb_fake, monkey_patched_key_dynamodb, table_fake, key_fake):
    expected_result = True
    client_error = exceptions.ConditionalCheckFailedException({'Error': {'Message: The conditional request failed.', 'Code': '400'}})
    actual_result = src.lambda_handler.does_key_exist(table= table_fake, key=key_fake)
    assert actual_result == expected_result

0 个答案:

没有答案