def test_custom_serializer(container_factory, rabbit_config,
                           sniffer_queue_factory):

    def encode(value):
        value = json.dumps(value)
        return value.upper()

    def decode(value):
        value = value.lower()
        return json.loads(value)

    register("upperjson", encode, decode, "application/x-upper-json", "utf-8")

    class Service(object):
        name = "service"

        @rpc
        def echo(self, arg):
            return arg

    rabbit_config[SERIALIZER_CONFIG_KEY] = "upperjson"
    container = container_factory(Service, rabbit_config)
    container.start()

    get_messages = sniffer_queue_factory('nameko-rpc')

    # verify RPC works end-to-end
    with ServiceRpcProxy('service', rabbit_config) as proxy:
        assert proxy.echo("hello") == "hello"

    # verify sniffed messages serialized as expected
    msg = get_messages()[0]
    assert msg['payload'] in '"RESULT": "HELLO"'
    assert msg['properties']['content_type'] == "application/x-upper-json"
dataset/ETHPy150Open onefinestay/nameko/test/test_serialization.py/test_custom_serializer/swapped operands of `in`