Skip to content

Commit

Permalink
test(api): fix test errors (#2417)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t authored Oct 4, 2018
1 parent f1e8d33 commit c19d57c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/opentrons/hardware_control/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict
from opentrons.util import environment
from opentrons.drivers.smoothie_drivers import driver_3_0
from opentrons.robot import robot_configs
from opentrons.legacy_api.robot import robot_configs

_lock = threading.Lock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,26 @@ def _mock_send_command(self, command, timeout=None):

def test_fail_get_temp_deck_temperature():
# Get the curent and target temperatures
# If no target temp has been previously set,
# then the response will set 'T' to 'none'
# If get fails, temp_deck temperature is not updated
import types
from opentrons.drivers.temp_deck import TempDeck

temp_deck = TempDeck()
temp_deck.simulating = False
return_string = 'T:none C:90'

def _mock_send_command(self, command, timeout=None):
return return_string
def _mock_send_command1(self, command, timeout=None):
return 'T:none C:90'

temp_deck._send_command = types.MethodType(_mock_send_command, temp_deck)
temp_deck._send_command = types.MethodType(_mock_send_command1, temp_deck)

temp_deck.update_temperature()

assert temp_deck._temperature == {'current': 90, 'target': None}

return_string = 'Tx:none C:1'
def _mock_send_command2(self, command, timeout=None):
return 'Tx:none C:1' # Failure premise

def _mock_send_command(self, command, timeout=None):
return return_string

temp_deck._send_command = types.MethodType(_mock_send_command, temp_deck)
temp_deck._send_command = types.MethodType(_mock_send_command2, temp_deck)

temp_deck.update_temperature()
assert temp_deck._temperature == {'current': 90, 'target': None}
Expand Down

0 comments on commit c19d57c

Please sign in to comment.