def test_setup_scanner_timeout():
    """Test setup_scanner failure from timeout."""
    with patch("aprslib.IS.connect", side_effect=TimeoutError):
        hass = get_test_home_assistant()
        hass.start()

        config = {
            "username": TEST_CALLSIGN,
            "password": TEST_PASSWORD,
            "host": "localhost",
            "timeout": 0.01,
            "callsigns": ["XX0FOO*", "YY0BAR-1"],
        }

        see = Mock()
        assert not device_tracker.setup_scanner(hass, config, see)
        hass.stop()
示例#2
0
def test_setup_scanner_timeout():
    """Test setup_scanner failure from timeout."""
    hass = get_test_home_assistant()
    hass.start()

    config = {
        "username": TEST_CALLSIGN,
        "password": TEST_PASSWORD,
        "host": "localhost",
        "timeout": 0.01,
        "callsigns": ["XX0FOO*", "YY0BAR-1"],
    }

    see = Mock()
    try:
        assert not device_tracker.setup_scanner(hass, config, see)
    finally:
        hass.stop()
示例#3
0
def test_setup_scanner_timeout():
    """Test setup_scanner failure from timeout."""
    hass = get_test_home_assistant()
    hass.start()

    config = {
        'username': TEST_CALLSIGN,
        'password': TEST_PASSWORD,
        'host': "localhost",
        'timeout': 0.01,
        'callsigns': ['XX0FOO*', 'YY0BAR-1']
    }

    see = Mock()
    try:
        assert not device_tracker.setup_scanner(hass, config, see)
    finally:
        hass.stop()
示例#4
0
def test_setup_scanner():
    """Test setup_scanner."""
    with patch('homeassistant.components.'
               'aprs.device_tracker.AprsListenerThread') as listener:
        hass = get_test_home_assistant()
        hass.start()

        config = {
            'username': TEST_CALLSIGN,
            'password': TEST_PASSWORD,
            'host': TEST_HOST,
            'callsigns': ['XX0FOO*', 'YY0BAR-1']
        }

        see = Mock()
        res = device_tracker.setup_scanner(hass, config, see)
        hass.bus.fire(EVENT_HOMEASSISTANT_START)
        hass.stop()

        assert res
        listener.assert_called_with(TEST_CALLSIGN, TEST_PASSWORD, TEST_HOST,
                                    'b/XX0FOO* b/YY0BAR-1', see)
示例#5
0
def test_setup_scanner():
    """Test setup_scanner."""
    with patch("homeassistant.components."
               "aprs.device_tracker.AprsListenerThread") as listener:
        hass = get_test_home_assistant()
        hass.start()

        config = {
            "username": TEST_CALLSIGN,
            "password": TEST_PASSWORD,
            "host": TEST_HOST,
            "callsigns": ["XX0FOO*", "YY0BAR-1"],
        }

        see = Mock()
        res = device_tracker.setup_scanner(hass, config, see)
        hass.bus.fire(EVENT_HOMEASSISTANT_START)
        hass.stop()

        assert res
        listener.assert_called_with(TEST_CALLSIGN, TEST_PASSWORD, TEST_HOST,
                                    "b/XX0FOO* b/YY0BAR-1", see)