Ejemplo n.º 1
0
 def test_should_return_next_seq(self):
     sert(xmod._next_seq(0)).to_equal(1)
     for i in range(1, 255):
         sert(xmod._next_seq(i)).to_equal(i + 1)
     sert(xmod._next_seq(255)).to_equal(1)
     sert(xmod._next_seq(256)).to_equal(2)
     sert(xmod._next_seq(257)).to_equal(3)
Ejemplo n.º 2
0
    def test_should_set_wav_file(self):
        filename = 'abc.wav'
        sert(tx.wav_file).to_equal(None)

        tx.set_wav_filename(filename)

        sert(tx.wav_file).to_equal(filename)
Ejemplo n.º 3
0
    def test_should_clear_record_session(self):
        filename = None
        tx.record_session = True

        tx.set_wav_filename(filename)

        sert(tx.record_session).is_false()
Ejemplo n.º 4
0
    def test_should_call_set_config(self):
        d = src.dispatcher.Dispatcher()
        d.set_config = Mock()

        d.exec_line('set wx yz')

        sert(d.set_config).called_once_with('wx yz')
Ejemplo n.º 5
0
    def test_should_update_start_time(self):
        tx.run()
        sert(tx.started_at).to_equal(0)

        tx.write_bytes([65])

        sert(tx.started_at).to_equal(123)
Ejemplo n.º 6
0
    def test_should_call_peek(self):
        d = src.dispatcher.Dispatcher()
        d.peek = Mock()

        d.exec_line('peek')

        sert(d.peek).called_once()
Ejemplo n.º 7
0
    def test_should_call_script(self):
        d = src.dispatcher.Dispatcher()
        d.script = Mock()

        d.exec_line('script abc.txt')

        sert(d.script).called_once_with('abc.txt')
Ejemplo n.º 8
0
    def test_should_return_true_value(self):
        d = src.dispatcher.Dispatcher()
        d.done = True

        ans = d.is_done()

        sert(ans).is_true()
Ejemplo n.º 9
0
    def test_should_return_false_value(self):
        d = src.dispatcher.Dispatcher()
        d.done = False

        ans = d.is_done()

        sert(ans).is_false()
Ejemplo n.º 10
0
    def test_should_reset_prompt(self):
        d.proc_serial()
        sert(d.prompt).to_equal('serial> ')

        d.quit()

        sert(d.prompt).to_equal('> ')
Ejemplo n.º 11
0
    def test_should_reset_cmd_proc(self):
        d.proc_serial()
        sert(d.prompt).not_equal(None)

        d.quit()

        sert(d.cmd_proc).to_equal(None)
Ejemplo n.º 12
0
    def test_should_echo(self, mock_i):
        txt = 'some text'
        d = src.dispatcher.Dispatcher()

        d.echo(txt)

        sert(mock_i).called_once_with(txt)
Ejemplo n.º 13
0
    def test_should_stop_transport(self):
        d = src.dispatcher.Dispatcher()
        d.transport = Mock()

        cmd = d.stop_transport()

        sert(d.transport.stop_it).called_once()
Ejemplo n.º 14
0
    def test_should_handle_read_ini_error(self, mock_i, mock_e, mock_open):
        mock_open.side_effect = IOError('bad thing')

        d = src.dispatcher.Dispatcher(targs(init='abc.ini'))

        sert(mock_i).called_once_with('Reading init script abc.ini')
        sert(mock_e).called_once_with('Error reading abc.ini')
Ejemplo n.º 15
0
    def test_should_call_help(self):
        d = src.dispatcher.Dispatcher()
        d.help = Mock()

        d.exec_line('help')

        sert(d.help).called_once()
Ejemplo n.º 16
0
    def test_should_set_value_true_value(self):
        d = src.dispatcher.Dispatcher()
        d.done = False

        d.force_done()

        sert(d.done).is_true()
Ejemplo n.º 17
0
    def test_should_call_listen(self):
        d = src.dispatcher.Dispatcher()
        d.listen = Mock()

        d.exec_line('listen 4 5')

        sert(d.listen).called_once_with('4 5')
Ejemplo n.º 18
0
    def test_should_call_quit(self):
        d = src.dispatcher.Dispatcher()
        d.quit = Mock()

        d.exec_line('quit')

        sert(d.quit).called_once()
Ejemplo n.º 19
0
    def test_should_call_wait(self):
        d = src.dispatcher.Dispatcher()
        d.wait = Mock()

        d.exec_line('wait 15')

        sert(d.wait).called_once_with('15')
Ejemplo n.º 20
0
    def test_should_call_subproc(self):
        d = src.dispatcher.Dispatcher()
        d.cmd_proc = Mock()

        d.exec_line('ab cd ef')

        sert(d.cmd_proc.exec_line).called_once_with('ab cd ef')
Ejemplo n.º 21
0
    def test_should_call_show_config(self):
        d = src.dispatcher.Dispatcher()
        d.show_config = Mock()

        d.exec_line('show ab cd')

        sert(d.show_config).called_once_with('ab cd')
Ejemplo n.º 22
0
    def test_should_call_echo(self):
        d = src.dispatcher.Dispatcher()
        d.echo = Mock()

        d.exec_line('echo abc')

        sert(d.echo).called_once_with('abc')
Ejemplo n.º 23
0
    def test_should_return_none_for_bad_key(self):
        key = 'bad-key'
        d = src.dispatcher.Dispatcher()

        ans = d._get_config_val(key)

        sert(ans).to_equal(None)
Ejemplo n.º 24
0
    def test_should_call_proc_serial(self):
        d = src.dispatcher.Dispatcher()
        d.proc_serial = Mock()

        d.exec_line('serial a scmd')

        sert(d.proc_serial).called_once_with('a scmd')
Ejemplo n.º 25
0
    def test_should_clear_session_buffer(self):
        filename = None
        tx.session_buffer = [33, 44]

        tx.set_wav_filename(filename)

        sert(tx.session_buffer).to_equal([])
Ejemplo n.º 26
0
    def test_should_call_proc_kermit(self):
        d = src.dispatcher.Dispatcher()
        d.proc_kermit = Mock()

        d.exec_line('kermit a kcmd')

        sert(d.proc_kermit).called_once_with('a kcmd')
Ejemplo n.º 27
0
    def test_should_set_record_session(self):
        filename = 'abc.wav'
        sert(tx.record_session).is_false()

        tx.set_wav_filename(filename)

        sert(tx.record_session).is_true()
Ejemplo n.º 28
0
    def test_should_call_proc_xmodem(self):
        d = src.dispatcher.Dispatcher()
        d.proc_xmodem = Mock()

        d.exec_line('xmodem a xcmd')

        sert(d.proc_xmodem).called_once_with('a xcmd')
Ejemplo n.º 29
0
    def test_should_open_pyaudio(self):
        mock_pa = mock_txpa.get_instance
        sert(mock_pa, 'open').not_called()

        tx.run()

        sert(mock_pa, 'open').called_once()
Ejemplo n.º 30
0
    def test_should_return_false(self, mock_stdin):
        mock_stdin.read = Mock(return_value='xyz')
        xmod._send_bytes = Mock(return_value=False)

        ans = xmod.send_file('STDIN')

        sert(ans).is_false()