mirror of
https://github.com/lowobservable/coax.git
synced 2026-04-25 20:01:47 +00:00
Refactor base interface for easier testing
This commit is contained in:
@@ -16,11 +16,7 @@ class Interface:
|
|||||||
"""Execute one or more commands."""
|
"""Execute one or more commands."""
|
||||||
(normalized_commands, has_multiple_commands) = _normalize_commands(commands)
|
(normalized_commands, has_multiple_commands) = _normalize_commands(commands)
|
||||||
|
|
||||||
(outbound_frames, response_lengths) = _pack_outbound_frames(normalized_commands)
|
responses = self._execute(normalized_commands, timeout)
|
||||||
|
|
||||||
inbound_frames = self._transmit_receive(outbound_frames, response_lengths, timeout)
|
|
||||||
|
|
||||||
responses = _unpack_inbound_frames(inbound_frames, normalized_commands)
|
|
||||||
|
|
||||||
if has_multiple_commands:
|
if has_multiple_commands:
|
||||||
return responses
|
return responses
|
||||||
@@ -32,6 +28,15 @@ class Interface:
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def _execute(self, commands, timeout):
|
||||||
|
(outbound_frames, response_lengths) = _pack_outbound_frames(commands)
|
||||||
|
|
||||||
|
inbound_frames = self._transmit_receive(outbound_frames, response_lengths, timeout)
|
||||||
|
|
||||||
|
responses = _unpack_inbound_frames(inbound_frames, commands)
|
||||||
|
|
||||||
|
return responses
|
||||||
|
|
||||||
def _transmit_receive(self, outbound_frames, response_lengths, timeout):
|
def _transmit_receive(self, outbound_frames, response_lengths, timeout):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user