Example #1
0
    def test_event_handler_option_decorator(self):
        view = Core()

        @view
        @delay
        def on_click(_):
            pass

        @view
        @delay
        def on_change(_):
            pass

        assert view._render_events(
        )['hx-trigger'] == 'change delay:0.5s,click delay:0.5s'

        view.remove_event('change')

        assert view._render_events()['hx-trigger'] == 'click delay:0.5s'
Example #2
0
    def test_event_handler_decorator(self):
        view = Core()

        with pytest.raises(ValueError):

            @view
            def on_nonexistent_event(_):
                pass

        @view
        def on_click(_):
            pass

        assert inspect.isfunction(
            view.on_click)  # noqa: Too clever for PyCharm
        assert view._render_events() == {
            'hx-post': '/event',
            'hx-trigger': 'click'
        }