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