Exemplo n.º 1
0
 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'
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
    def _write(self, cmd, *datas):
        if not isinstance(cmd, Command):
            cmd = Command(write=cmd)

        cmd.write(self._transport, self._protocol, *datas)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
 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']
Exemplo n.º 7
0
 def test_write_without_data(self):
     protocol = MockProtocol()
     transport = MockTransport()
     cmd = Command(write='HEADER')
     cmd.write(transport, protocol)