Skip to content

Commit 5c0a4d3

Browse files
committed
Tests.
1 parent d3a89d0 commit 5c0a4d3

File tree

9 files changed

+14
-17
lines changed

9 files changed

+14
-17
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Arduino simpleRPC API client library and CLI
55
:target: https://github.com/jfjlaros/arduino-simple-rpc/graphs/commit-activity
66
.. image:: https://github.com/jfjlaros/arduino-simple-rpc/actions/workflows/python-package.yml/badge.svg
77
:target: https://github.com/jfjlaros/arduino-simple-rpc/actions/workflows/python-package.yml
8-
.. image:: https://readthedocs.org/projects/simplerpc/badge/?version=latest
8+
.. image:: https://readthedocs.org/projects/arduino-simple-rpc/badge/?version=latest
99
:target: https://arduino-simple-rpc.readthedocs.io/en/latest
1010
.. image:: https://img.shields.io/github/release-date/jfjlaros/arduino-simple-rpc.svg
1111
:target: https://github.com/jfjlaros/arduino-simple-rpc/releases

examples/demo/demo.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from simple_rpc import Interface
44

55

6-
device = '/dev/ttyACM0'
6+
device = '/dev/ttyUSB0'
77
cycles = 20
88

99

@@ -12,8 +12,6 @@
1212
interface = Interface(device)
1313
stdout.write('done.\n\n')
1414

15-
stdout.write('Protocol version: {}\n\n'.format(interface._version))
16-
1715
i = 0
1816
while i < 10:
1917
stdout.write('Ping: sent {}, received {}.\n'.format(i, interface.ping(i)))

simple_rpc/cli.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def _arg_parser() -> object:
100100
common_parser.add_argument(
101101
'device', metavar='DEVICE', type=str, help='device')
102102
common_parser.add_argument(
103-
'-b', dest='baudrate', type=int, default=9600,
104-
help='baud rate')
103+
'-b', dest='baudrate', type=int, default=9600, help='baud rate')
105104
common_parser.add_argument(
106105
'-w', dest='wait', type=int, default=2,
107106
help='time before communication starts')

simple_rpc/simple_rpc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
_protocol = 'simpleRPC'
16-
_version = (3, 0, 0)
16+
_version = (4, 0, 0)
1717

1818
_list_req = 0xff
1919

tests/__init__.py

Whitespace-only changes.

tests/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
_devices = {
5-
'serial': '/dev/ttyACM0',
5+
'serial': '/dev/ttyUSB0',
66
'wifi': 'socket://192.168.21.53:1025',
77
'bt': '/dev/rfcomm0'}
88
_interface = """
@@ -24,7 +24,7 @@
2424
protocol: simpleRPC
2525
size_t: H
2626
version: !!python/tuple
27-
- 3
27+
- 4
2828
- 0
2929
- 0
3030
""".format(''.join(map('- {}\n'.format, _version)))

tests/test_cli.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from simple_rpc.cli import _describe_method, rpc_call, rpc_list
77
from simple_rpc.extras import json_utf8_decode, json_utf8_encode
88

9-
from conf import _devices, _interface
9+
from .conf import _devices, _interface
1010

1111

1212
def test_json_utf8_encode() -> None:
@@ -36,7 +36,7 @@ def test_describe_method() -> None:
3636
def test_rpc_list() -> None:
3737
handle = StringIO()
3838

39-
rpc_list(handle, _devices['serial'], 9600, 1, None)
39+
rpc_list(handle, _devices['serial'], 9600, 2, None)
4040
assert 'ping data\n Echo a value.\n' in handle.getvalue()
4141

4242

@@ -45,7 +45,7 @@ def test_rpc_list_save() -> None:
4545
handle = StringIO()
4646
iface_handle = StringIO()
4747

48-
rpc_list(handle, _devices['serial'], 9600, 1, iface_handle)
48+
rpc_list(handle, _devices['serial'], 9600, 2, iface_handle)
4949
iface_handle.seek(0)
5050
device = load(iface_handle, Loader=FullLoader)
5151
assert device['methods']['ping']['doc'] == 'Echo a value.'
@@ -55,7 +55,7 @@ def test_rpc_list_save() -> None:
5555
def test_rpc_call() -> None:
5656
handle = StringIO()
5757

58-
rpc_call(handle, _devices['serial'], 9600, 1, None, 'ping', ['10'])
58+
rpc_call(handle, _devices['serial'], 9600, 2, None, 'ping', ['10'])
5959
assert handle.getvalue() == '10\n'
6060

6161

@@ -65,7 +65,7 @@ def test_rpc_call_load() -> None:
6565
iface_handle = StringIO(_interface)
6666

6767
rpc_call(
68-
handle, _devices['serial'], 9600, 1, iface_handle, 'ping', ['10'])
68+
handle, _devices['serial'], 9600, 2, iface_handle, 'ping', ['10'])
6969
assert handle.getvalue() == '10\n'
7070

7171

@@ -76,7 +76,7 @@ def test_rpc_call_load_() -> None:
7676

7777
try:
7878
rpc_call(
79-
handle, _devices['serial'], 9600, 1, iface_handle, 'inc', ['1'])
79+
handle, _devices['serial'], 9600, 2, iface_handle, 'inc', ['1'])
8080
except ValueError as error:
8181
assert str(error) == 'invalid method name: inc'
8282
else:

tests/test_device.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from simple_rpc import Interface
77
from simple_rpc.simple_rpc import _version
88

9-
from conf import _devices, _interface
9+
from .conf import _devices, _interface
1010

1111

1212
class _TestDevice(object):

tests/test_simple_rpc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SerialInterface, SocketInterface, Interface,
33
_assert_protocol, _assert_version, _protocol, _version)
44

5-
from conf import _devices
5+
from .conf import _devices
66

77

88
def test_assert_protocol_pass() -> None:

0 commit comments

Comments
 (0)