def test_signal_exception_post_signal(mock_uuid, mock_req): pre_recorded = [] UUID = '123-abc' def record_pre_dynamodb_send(sender, operation_name, table_name, req_uuid): pre_recorded.append((operation_name, table_name, req_uuid)) def record_post_dynamodb_send(sender, operation_name, table_name, req_uuid): raise ValueError() pre_dynamodb_send.connect(record_pre_dynamodb_send) post_dynamodb_send.connect(record_post_dynamodb_send) try: mock_uuid.uuid4.return_value = UUID mock_req.return_value = {'TableDescription': {'TableName': 'table', 'TableStatus': 'Creating'}} c = Connection() c.dispatch('CreateTable', {'TableName': 'MyTable'}) assert ('CreateTable', 'MyTable', UUID) == pre_recorded[0] finally: pre_dynamodb_send.disconnect(record_pre_dynamodb_send) post_dynamodb_send.disconnect(record_post_dynamodb_send)
def test_signal_exception_post_signal(mock_uuid, mock_req): pre_recorded = [] UUID = '123-abc' def record_pre_dynamodb_send(sender, operation_name, table_name, req_uuid): pre_recorded.append((operation_name, table_name, req_uuid)) def record_post_dynamodb_send(sender, operation_name, table_name, req_uuid): raise ValueError() pre_dynamodb_send.connect(record_pre_dynamodb_send) post_dynamodb_send.connect(record_post_dynamodb_send) try: mock_uuid.uuid4.return_value = UUID mock_req.return_value = {'TableDescription': {'TableName': 'table', 'TableStatus': 'Creating'}} c = Connection() c.dispatch('CreateTable', {'TableName': 'MyTable'}) assert ('CreateTable', 'MyTable', UUID) == pre_recorded[0] finally: pre_dynamodb_send.disconnect(record_pre_dynamodb_send) post_dynamodb_send.disconnect(record_post_dynamodb_send)
def test_fake_signals(): _signals = _FakeNamespace() pre_dynamodb_send = _signals.signal('pre_dynamodb_send') with pytest.raises(RuntimeError): pre_dynamodb_send.connect(lambda x: x) pre_dynamodb_send.send(object, operation_name="UPDATE", table_name="TEST", req_uuid="something")
def test_fake_signals(): _signals = _FakeNamespace() pre_dynamodb_send = _signals.signal('pre_dynamodb_send') with pytest.raises(RuntimeError): pre_dynamodb_send.connect(lambda x: x) pre_dynamodb_send.send(object, operation_name="UPDATE", table_name="TEST", req_uuid="something")