def test_write_with_query_only_cmd(self): protocol = MockProtocol() transport = MockTransport() cmd = Command(('HEADER', Integer)) with pytest.raises(AttributeError) as excinfo: cmd.write(transport, protocol) assert str(excinfo.value) == 'Command is not writeable'
def test_write_with_generator_type(self): protocol = MockProtocol() transport = MockTransport() cmd = Command(write=('HEADER', it.repeat(Integer()))) cmd.write(transport, protocol, 1, 2, 3) assert protocol.transport == transport assert protocol.header == 'HEADER' assert protocol.data == ('1', '2', '3')
def test_write(self): protocol = MockProtocol() transport = MockTransport() cmd = Command(write=('HEADER', [Integer, Integer])) cmd.write(transport, protocol, 1, 2) assert protocol.transport == transport assert protocol.header == 'HEADER' assert protocol.data == ('1', '2')
def _write(self, cmd, *datas): if not isinstance(cmd, Command): cmd = Command(write=cmd) cmd.write(self._transport, self._protocol, *datas)
def _write(self, cmd, *datas): if not isinstance(cmd, Command): cmd = Command(write=cmd) # TODO: remove self._transport from the call cmd.write(self._transport, self._protocol, *datas)
def test_write_with_simulation(self): protocol = MockProtocol() transport = SimulatedTransport() cmd = Command(write=('HEADER', [Integer, Integer])) cmd.write(transport, protocol, 1, 2) assert cmd._simulation_buffer == ['1', '2']
def test_write_without_data(self): protocol = MockProtocol() transport = MockTransport() cmd = Command(write='HEADER') cmd.write(transport, protocol)