def test_autosave_component_set_interval(mocker): """Test that setting the interval does indeed change it and calls do_autosave if enabled.""" mocker.patch.object(AutosaveForPlugin, 'do_autosave') addon = AutosaveForPlugin(None) addon.do_autosave.assert_not_called() addon.interval = 10000 assert addon.interval == 10000 addon.do_autosave.assert_not_called() addon.enabled = True addon.interval = 20000 assert addon.do_autosave.called
def test_autosave_component_set_interval(qtbot, mocker): """Test that setting the interval does indeed change it and calls do_autosave if enabled.""" mocker.patch.object(AutosaveForPlugin, 'do_autosave') addon = AutosaveForPlugin(None) addon.do_autosave.assert_not_called() addon.interval = 10000 assert addon.interval == 10000 addon.do_autosave.assert_not_called() addon.enabled = True addon.interval = 20000 assert addon.do_autosave.called
def test_autosave_component_timer_if_enabled(qtbot, mocker, enabled): """Test that AutosaveForPlugin calls do_autosave() on timer if enabled.""" mocker.patch.object(AutosaveForPlugin, 'do_autosave') addon = AutosaveForPlugin(None) addon.do_autosave.assert_not_called() addon.interval = 100 addon.enabled = enabled qtbot.wait(500) if enabled: assert addon.do_autosave.called else: addon.do_autosave.assert_not_called()