def test__publish_over_sns(mock_get_sns_client, message): message.validate() topic = _get_sns_topic(message) message_json = _convert_to_json(message.as_dict()) _publish_over_sns(topic, message_json, message.headers) mock_get_sns_client.assert_called_once_with() mock_get_sns_client.return_value.publish.assert_called_once_with( TopicArn=topic, Message=message_json, MessageAttributes={ k: { 'DataType': 'String', 'StringValue': str(v) } for k, v in message.headers.items() }, )
def test__convert_to_json_non_serializable(message_data): message_data['data']['vin'] = object() with pytest.raises(TypeError): _convert_to_json(message_data)
def test__convert_to_json_decimal(value, message_data): message_data['data']['vin'] = Decimal(value) assert json.loads(_convert_to_json(message_data))['data']['vin'] == float( message_data['data']['vin'])
def test__convert_to_json_decimal(message_with_decimal): assert json.loads(_convert_to_json(message_with_decimal.as_dict()))['data']['user_id'] == \ float(message_with_decimal.data['user_id'])