コード例 #1
0
def test_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'
    import types
    from opentrons.drivers.temp_deck import TempDeck

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

    def _mock_send_command(self, command, timeout=None, tag=None):
        nonlocal command_log, return_string
        command_log += [command]
        return return_string

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

    assert temp_deck.temperature == 25  # driver's initialized value
    assert temp_deck.target is None
    temp_deck.update_temperature()
    assert command_log == ['M105']
    assert temp_deck.temperature == 90
    assert temp_deck.target is None

    command_log = []
    return_string = 'T:99 C:90'
    temp_deck.update_temperature()
    assert command_log == ['M105']
    assert temp_deck.temperature == 90
    assert temp_deck.target == 99
コード例 #2
0
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'
    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

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

    temp_deck.update_temperature()

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

    return_string = 'Tx:none C:1'

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

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

    temp_deck.update_temperature()
    assert temp_deck._temperature == {'current': 90, 'target': None}
コード例 #3
0
def test_fail_get_temp_deck_temperature():
    # Get the curent and target temperatures
    # 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

    done = False

    def _mock_send_command1(self, command, timeout=None, tag=None):
        nonlocal done
        done = True
        return 'T:none C:90'

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

    temp_deck.update_temperature()
    time.sleep(0.25)
    while not done:
        time.sleep(0.25)

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

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

    temp_deck._send_command = types.MethodType(_mock_send_command2, temp_deck)
    done = False
    temp_deck.update_temperature()
    time.sleep(0.25)
    while not done:
        time.sleep(0.25)
    assert temp_deck._temperature == {'current': 90, 'target': None}