def test_check_basic_change_detection_functionality(client, live_server):
    set_original_response()
    live_server_setup(live_server)
    res = client.post(url_for('import_page'), data={'urls': url_for('test_endpoint', _external=True)}, follow_redirects=True)
    assert (b'1 Imported' in res.data)
    time.sleep(sleep_time_for_fetch_thread)
    for n in range(3):
        client.get(url_for('api_watch_checknow'), follow_redirects=True)
        time.sleep(sleep_time_for_fetch_thread)
        res = client.get(url_for('index'))
        assert (b'unviewed' not in res.data)
        assert (b'test-endpoint' in res.data)
        assert (b'SETTINGS' in res.data)
        assert (b'BACKUP' in res.data)
        assert (b'IMPORT' in res.data)
    res = client.get(url_for('preview_page', uuid='first'), follow_redirects=True)
    assert (b'foobar-detection' not in res.data)
    set_modified_response()
    res = urlopen(url_for('test_endpoint', _external=True))
    assert (b'which has this one new line' in res.read())
    res = client.get(url_for('api_watch_checknow'), follow_redirects=True)
    assert (b'1 watches are queued for rechecking.' in res.data)
    time.sleep(sleep_time_for_fetch_thread)
    res = client.get(url_for('index'))
    assert (b'unviewed' in res.data)
    res = client.get(url_for('rss'))
    expected_url = url_for('test_endpoint', _external=True)
    assert (b'<rss' in res.data)
    assert (b'(into   ) which has this one new line' in res.data)
    assert (b'CDATA' in res.data)
    assert (expected_url.encode('utf-8') in res.data)
    res = client.get(url_for('diff_history_page', uuid='first'))
    assert (b'Compare newest' in res.data)
    time.sleep(2)
    for n in range(2):
        client.get(url_for('api_watch_checknow'), follow_redirects=True)
        time.sleep(sleep_time_for_fetch_thread)
        res = client.get(url_for('index'))
        assert (b'unviewed' not in res.data)
        assert (b'head title' not in res.data)
        assert (b'test-endpoint' in res.data)
    set_original_response()
    res = client.post(url_for('settings_page'), data={'extract_title_as_title': '1', 'minutes_between_check': 180, 'fetch_backend': 'html_requests'}, follow_redirects=True)
    client.get(url_for('api_watch_checknow'), follow_redirects=True)
    time.sleep(sleep_time_for_fetch_thread)
    res = client.get(url_for('index'))
    assert (b'unviewed' in res.data)
    assert (b'head title' in res.data)
    res = client.get(url_for('api_delete', uuid='all'), follow_redirects=True)
    assert (b'Deleted' in res.data)
def test_check_basic_change_detection_functionality(client, live_server):
    set_original_response()
    live_server_setup(live_server)
    res = client.post(url_for('import_page'), data={'urls': url_for('test_endpoint', _external=True)}, follow_redirects=True)
    assert (b'1 Imported' in res.data)
    time.sleep(sleep_time_for_fetch_thread)
    for n in range(3):
        client.get(url_for('api_watch_checknow'), follow_redirects=True)
        time.sleep(sleep_time_for_fetch_thread)
        res = client.get(url_for('index'))
        assert (b'unviewed' not in res.data)
        assert (b'test-endpoint' in res.data)
        assert (b'SETTINGS' in res.data)
        assert (b'BACKUP' in res.data)
        assert (b'IMPORT' in res.data)
    res = client.get(url_for('preview_page', uuid='first'), follow_redirects=True)
    assert (b'foobar-detection' not in res.data)
    set_modified_response()
    res = urlopen(url_for('test_endpoint', _external=True))
    assert (b'which has this one new line' in res.read())
    res = client.get(url_for('api_watch_checknow'), follow_redirects=True)
    assert (b'1 watches are queued for rechecking.' in res.data)
    time.sleep(sleep_time_for_fetch_thread)
    res = client.get(url_for('index'))
    assert (b'unviewed' in res.data)
    res = client.get(url_for('rss'))
    expected_url = url_for('test_endpoint', _external=True)
    assert (b'<rss' in res.data)
    assert (b'(into   ) which has this one new line' in res.data)
    assert (b'CDATA' in res.data)
    assert (expected_url.encode('utf-8') in res.data)
    res = client.get(url_for('diff_history_page', uuid='first'))
    assert (b'Compare newest' in res.data)
    time.sleep(2)
    for n in range(2):
        client.get(url_for('api_watch_checknow'), follow_redirects=True)
        time.sleep(sleep_time_for_fetch_thread)
        res = client.get(url_for('index'))
        assert (b'unviewed' not in res.data)
        assert (b'head title' not in res.data)
        assert (b'test-endpoint' in res.data)
    set_original_response()
    res = client.post(url_for('settings_page'), data={'extract_title_as_title': '1', 'minutes_between_check': 180, 'fetch_backend': 'html_requests'}, follow_redirects=True)
    client.get(url_for('api_watch_checknow'), follow_redirects=True)
    time.sleep(sleep_time_for_fetch_thread)
    res = client.get(url_for('index'))
    assert (b'unviewed' in res.data)
    assert (b'head title' in res.data)
    res = client.get(url_for('api_delete', uuid='all'), follow_redirects=True)
    assert (b'Deleted' in res.data)