from django.apps import apps
from django.test import override_settings

from wagtail_live.signals import live_page_update


def test_live_page_update_signal_receivers():
    assert len(live_page_update.receivers) == 0


@override_settings(
    WAGTAIL_LIVE_PUBLISHER="tests.testapp.publishers.DummyWebsocketPublisher"
)
def test_live_page_update_signal_receivers_websocket():
    app_config = apps.get_app_config("wagtail_live")
    app_config.ready()

    try:
        # Receiver should be connected, no IndexError
        receiver = live_page_update.receivers[0]
    finally:
        live_page_update.disconnect(receiver)

[(11, 'django.test.override_settings', 'override_settings', False, 'from django.test import override_settings\n'), (15, 'django.apps.apps.get_app_config', 'apps.get_app_config', False, 'from django.apps import apps\n'), (22, 'wagtail_live.signals.live_page_update.disconnect', 'live_page_update.disconnect', False, 'from wagtail_live.signals import live_page_update\n')]