-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,30 @@ | ||
from simple_rpc.simple_rpc import _version | ||
|
||
|
||
_devices = { | ||
'serial': '/dev/ttyACM0', | ||
'wifi': 'socket://192.168.21.53:1025', | ||
'bt': '/dev/rfcomm0'} | ||
_interface = """ | ||
endianness: < | ||
methods: | ||
ping: | ||
doc: Echo a value. | ||
index: 0 | ||
name: ping | ||
parameters: | ||
- doc: Value. | ||
fmt: B | ||
name: data | ||
typename: int | ||
return: | ||
doc: Value of data. | ||
fmt: B | ||
typename: int | ||
protocol: simpleRPC | ||
size_t: H | ||
version: !!python/tuple | ||
- 3 | ||
- 0 | ||
- 0 | ||
""".format(''.join(map('- {}\n'.format, _version))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from simple_rpc.simple_rpc import ( | ||
SerialInterface, SocketInterface, Interface, | ||
_assert_protocol, _assert_version, _protocol, _version) | ||
|
||
from conf import _devices | ||
|
||
|
||
def test_assert_protocol_pass() -> None: | ||
_assert_protocol(_protocol) | ||
|
||
|
||
def test_assert_protocol_fail() -> None: | ||
try: | ||
_assert_protocol('') | ||
except ValueError as error: | ||
assert str(error) == 'invalid protocol header' | ||
else: | ||
assert False | ||
|
||
|
||
def test_assert_version_pass() -> None: | ||
_assert_version(_version) | ||
|
||
|
||
def test_assert_version_fail() -> None: | ||
try: | ||
_assert_version((0, 0, 0)) | ||
except ValueError as error: | ||
assert str(error).startswith('version mismatch') | ||
else: | ||
assert False | ||
|
||
|
||
def test_SerialInterface() -> None: | ||
interface = Interface(_devices['serial'], autoconnect=False) | ||
assert isinstance(interface, SerialInterface) | ||
|
||
|
||
def test_SocketInterface() -> None: | ||
interface = Interface(_devices['wifi'], autoconnect=False) | ||
assert isinstance(interface, SocketInterface) |