コード例 #1
0
 def test_can_hydrate_extra_fields(self):
     from nautilus.conventions.actions import serialize_action, hydrate_action
     # the target
     target = dict(action_type='foo', payload='bar', foo='bar')
     # the serialized form of the object
     serialized = serialize_action(**target)
     # make sure we can hydrate the serialized form into the target
     assert hydrate_action(serialized) == target, (
         "Could not hydrate action with extra fields.")
コード例 #2
0
    def test_can_serialize_and_deserialize_action(self):
        from nautilus.conventions.actions import serialize_action, hydrate_action
        # the target
        target = dict(action_type='hello', payload='world')
        # the hydrated form of the object
        serialized = serialize_action(**target)

        # make sure we can hydrate the hydrated form into the target
        assert hydrate_action(serialized) == target, (
            "Could not serialize/deserialize action.")
コード例 #3
0
 def test_can_hydrate_extra_fields(self):
     from nautilus.conventions.actions import serialize_action, hydrate_action
     # the target
     target = dict(action_type='foo', payload='bar', foo='bar')
     # the serialized form of the object
     serialized = serialize_action(**target)
     # make sure we can hydrate the serialized form into the target
     assert hydrate_action(serialized) == target, (
         "Could not hydrate action with extra fields."
     )
コード例 #4
0
ファイル: kafka.py プロジェクト: nautilus/nautilus
    async def send(self, payload='', action_type='', channel=None, **kwds):
        """
            This method sends a message over the kafka stream.
        """
        # use a custom channel if one was provided
        channel = channel or self.producer_channel

        # serialize the action type for the
        message = serialize_action(action_type=action_type, payload=payload, **kwds)
        # send the message
        return await self._producer.send(channel, message.encode())
コード例 #5
0
    async def send(self, payload='', action_type='', channel=None, **kwds):
        """
            This method sends a message over the kafka stream.
        """
        # use a custom channel if one was provided
        channel = channel or self.producer_channel

        # serialize the action type for the
        message = serialize_action(action_type=action_type,
                                   payload=payload,
                                   **kwds)
        # send the message
        return await self._producer.send(channel, message.encode())
コード例 #6
0
    def test_can_serialize_and_deserialize_action(self):
        from nautilus.conventions.actions import serialize_action, hydrate_action
        # the target
        target = dict(
            action_type='hello',
            payload='world'
        )
        # the hydrated form of the object
        serialized = serialize_action(**target)

        # make sure we can hydrate the hydrated form into the target
        assert hydrate_action(serialized) == target, (
            "Could not serialize/deserialize action."
        )