

def test_watchdog_is_watchdoging(self):
    "Test if the watchdog: doesn't send message if one was sent, and send one if the channel is timing out."
    m = Main()
    m.tcp_connect()
    m.send_connect([('login', '4.test'), ('passcode', 'test')])
    m.get_frame()
    ownMessage = str(uuid.uuid4())
    m.send_frame('SEND', [('destination', (config.TEST_WATCHDOG_TOPIC[0][0] + 'text'))], ownMessage)
    m.send_frame('SUBSCRIBE', [('destination', (config.TEST_WATCHDOG_TOPIC[0][0] + 'text')), ('x-ebu-nofastreply', 'yes')], '')
    m.socket.settimeout((config.TEST_FB_FALLBACK_TIME / 2))
    ok = True
    try:
        while True:
            (result, _, body) = m.get_frame()
            if ((result != 'MESSAGE') or (body != ownMessage)):
                ok = False
    except Exception:
        pass
    if (not ok):
        raise Exception("Socket didn't timeout !")
    m.send_frame('SEND', [('destination', (config.TEST_WATCHDOG_TOPIC[0][0] + 'text'))], ownMessage)
    m.socket.settimeout((config.TEST_FB_FALLBACK_TIME - 1))
    try:
        while True:
            (result, _, body) = m.get_frame()
            if ((result != 'MESSAGE') or (body != ownMessage)):
                ok = False
    except Exception:
        pass
    if (not ok):
        raise Exception("Socket didn't timeout !")
    time.sleep((1 + (config.TEST_FB_FALLBACK_CHECK * 2)))
    m.socket.settimeout(1)
    (result, headers, body) = m.get_frame()
    eq_(result, 'MESSAGE')

dataset/ETHPy150Open ebu/radiodns-plugit/RadioVisServer/tests.py MainTests.test_watchdog_is_watchdoging/original