async def collect(self): while True: data = await self._socket.recv_multipart() _, action_data = data action = decode_object(action_data) logger.debug('Collected %s', action) return action
def test_decode_state(): result = decode_object(serialized_state) expected_state = RootState() assert result.state_type == expected_state.state_type assert result.root_prop == expected_state.root_prop assert result.leaf.state_type == expected_state.leaf.state_type assert result.leaf.leaf_prop == expected_state.leaf.leaf_prop
def test_decode_action(): action = decode_object(encoded_action) with freeze_time('2017-05-24'): expected_action = DummyAction() assert action.action_type == expected_action.action_type assert action.timestamp == expected_action.timestamp assert action.topic == action.topic
async def receive_action(self): data = await self.receive_encoded() _, action_data = data return decode_object(action_data)
async def receive_state(self): data = await self._socket.recv_multipart() action = decode_object(data[0]) return action
async def get_state_request(self): while True: data = await self._socket.recv_multipart() identity, action_data = data action = decode_object(action_data) return identity, action