예제 #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)
예제 #2
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    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)
예제 #3
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    def test_should_clear_record_session(self):
        filename = None
        tx.record_session = True

        tx.set_wav_filename(filename)

        sert(tx.record_session).is_false()
예제 #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')
예제 #5
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    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)
예제 #6
0
    def test_should_call_peek(self):
        d = src.dispatcher.Dispatcher()
        d.peek = Mock()

        d.exec_line('peek')

        sert(d.peek).called_once()
예제 #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')
예제 #8
0
    def test_should_return_true_value(self):
        d = src.dispatcher.Dispatcher()
        d.done = True

        ans = d.is_done()

        sert(ans).is_true()
예제 #9
0
    def test_should_return_false_value(self):
        d = src.dispatcher.Dispatcher()
        d.done = False

        ans = d.is_done()

        sert(ans).is_false()
예제 #10
0
    def test_should_reset_prompt(self):
        d.proc_serial()
        sert(d.prompt).to_equal('serial> ')

        d.quit()

        sert(d.prompt).to_equal('> ')
예제 #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)
예제 #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)
예제 #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()
예제 #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')
예제 #15
0
    def test_should_call_help(self):
        d = src.dispatcher.Dispatcher()
        d.help = Mock()

        d.exec_line('help')

        sert(d.help).called_once()
예제 #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()
예제 #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')
예제 #18
0
    def test_should_call_quit(self):
        d = src.dispatcher.Dispatcher()
        d.quit = Mock()

        d.exec_line('quit')

        sert(d.quit).called_once()
예제 #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')
예제 #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')
예제 #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')
예제 #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')
예제 #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)
예제 #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')
예제 #25
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    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([])
예제 #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')
예제 #27
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    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()
예제 #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')
예제 #29
0
파일: t_tx.py 프로젝트: deverac/hpircomm
    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()
예제 #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()