Пример #1
0
def test_update_check_disabled():
    gs = GlobalSettings()
    gs.settings.update_check_enabled = False

    responses.add_callback(
        responses.POST,
        "https://pretalx.com/.update_check/",
        callback=request_callback_disallowed,
        content_type="application/json",
    )
    update_check.apply(throw=True)
Пример #2
0
def test_update_check_sent_no_updates():
    responses.add_callback(
        responses.POST,
        "https://pretalx.com/.update_check/",
        callback=request_callback_not_updatable,
        content_type="application/json",
    )
    update_check.apply(throw=True)
    gs = GlobalSettings()
    assert not gs.settings.update_check_result_warning
    storeddata = gs.settings.update_check_result
    assert not storeddata["version"]["updatable"]
Пример #3
0
def test_result_table_up2date_with_plugins():
    responses.add_callback(
        responses.POST,
        "https://pretalx.com/.update_check/",
        callback=request_callback_with_plugin,
        content_type="application/json",
    )
    update_check.apply(throw=True)
    tbl = check_result_table()
    assert tbl[0] == ("pretalx", __version__, "1.0.0", True)
    assert tbl[1] == ("Plugin: test plugin for pretalx", "0.0.0", "1.1.1",
                      True)
Пример #4
0
def test_result_table_up2date():
    responses.add_callback(
        responses.POST,
        "https://pretalx.com/.update_check/",
        callback=request_callback_not_updatable,
        content_type="application/json",
    )
    update_check.apply(throw=True)
    tbl = check_result_table()
    assert tbl[0] == ("pretalx", __version__, "1.0.0", False)
    assert any(e[0] == "Plugin: test plugin for pretalx" for e in tbl)
    assert any(e[2] == "?" for e in tbl)
Пример #5
0
def test_update_check_mail_sent():
    gs = GlobalSettings()
    gs.settings.update_check_email = "*****@*****.**"

    responses.add_callback(
        responses.POST,
        "https://pretalx.com/.update_check/",
        callback=request_callback_updatable,
        content_type="application/json",
    )
    update_check.apply(throw=True)

    assert len(djmail.outbox) == 1
    assert djmail.outbox[0].to == ["*****@*****.**"]
    assert "update" in djmail.outbox[0].subject
Пример #6
0
def test_update_check_mail_sent_only_after_change():
    gs = GlobalSettings()
    gs.settings.update_check_email = "*****@*****.**"

    with responses.RequestsMock() as rsps:
        rsps.add_callback(
            responses.POST,
            "https://pretalx.com/.update_check/",
            callback=request_callback_updatable,
            content_type="application/json",
        )

        update_check.apply(throw=True)
        assert len(djmail.outbox) == 1

        update_check.apply(throw=True)
        assert len(djmail.outbox) == 1

    with responses.RequestsMock() as rsps:
        rsps.add_callback(
            responses.POST,
            "https://pretalx.com/.update_check/",
            callback=request_callback_not_updatable,
            content_type="application/json",
        )

        update_check.apply(throw=True)
        assert len(djmail.outbox) == 1

    with responses.RequestsMock() as rsps:
        rsps.add_callback(
            responses.POST,
            "https://pretalx.com/.update_check/",
            callback=request_callback_updatable,
            content_type="application/json",
        )

        update_check.apply(throw=True)
        assert len(djmail.outbox) == 2
Пример #7
0
 def post(self, request, *args, **kwargs):
     if "trigger" in request.POST:
         update_check.apply()
         return redirect(self.get_success_url())
     return super().post(request, *args, **kwargs)