def session(graph, config, bus, mocker): graph.register_instance("focusyn.bus", bus) graph.register_instance("focusyn.config", config) mocker.patch("uuid.uuid4", return_value="1234") scan_to_graph(["focusyn.pomodoro.timer", "focusyn.pomodoro.session"], graph) return graph.get("focusyn.session")
def test_module(bus, graph): graph.register_instance("focusyn.bus", bus) scan_to_graph(["focusyn.pomodoro.timer"], graph) instance = graph.get("focusyn.timer") assert isinstance(instance, Timer)
def app(graph, window, plugin_engine, mocker) -> Application: graph.register_instance("focusyn.ui.view", window) graph.register_instance("focusyn.plugin", plugin_engine) graph.register_instance("dbus.session", mocker.Mock()) scan_to_graph(["focusyn.pomodoro.app"], graph) return graph.get("focusyn.app")
def test_create_app_instance_when_it_is_not_registered_in_dbus(self, graph, window, plugin_engine): graph.register_instance("focusyn.ui.view", window) graph.register_instance("focusyn.plugin", plugin_engine) scan_to_graph(["focusyn.pomodoro.app"], graph) instance = Application.from_graph(graph, DBusTestCase.get_dbus()) assert isinstance(instance, Application)
def test_module(graph): scan_to_graph(["tomate.event"], graph) assert sorted(list(graph.providers)) == sorted([ "tomate.events.setting", "tomate.events.session", "tomate.events.timer", "tomate.events.view", ])
def test_module(bus, config, graph): graph.register_instance("tomate.bus", bus) graph.register_instance("tomate.config", config) scan_to_graph(["tomate.pomodoro.plugin"], graph) instance = graph.get("tomate.plugin") assert isinstance(instance, PluginEngine) assert instance == graph.get("tomate.plugin")
def test_about_module(graph, config): scan_to_graph(['tomate_gtk.dialogs.about'], graph) assert 'view.about' in graph.providers provider = graph.providers['view.about'] assert provider.scope == SingletonScope assert isinstance(graph.get('view.about'), AboutDialog)
def test_preference_duration_module(self, graph, config): scan_to_graph(['tomate_gtk.dialogs.preference'], graph) assert 'view.preference.duration' in graph.providers provider = graph.providers['view.preference.duration'] assert provider.scope == SingletonScope assert isinstance(graph.get('view.preference.duration'), TimerStack)
def test_preference_extension_module(self, graph, config, plugin_manager, lazy_proxy): scan_to_graph(['tomate_gtk.dialogs.preference'], graph) assert 'view.preference.extension' in graph.providers provider = graph.providers['view.preference.extension'] assert provider.scope == SingletonScope assert isinstance(graph.get('view.preference.extension'), ExtensionStack)
def test_preference_module(graph, bus, config, plugin_engine): graph.register_instance("tomate.bus", bus) graph.register_instance("tomate.plugin", plugin_engine) graph.register_instance("tomate.config", config) scan_to_graph(["tomate.ui.dialogs.preference"], graph) instance = graph.get("tomate.ui.preference") assert isinstance(instance, PreferenceDialog) assert graph.get("tomate.ui.preference") is instance
def test_timerframe_module(graph): scan_to_graph(['tomate_gtk.widgets.timerframe'], graph) assert 'view.timerframe' in graph.providers provider = graph.providers['view.timerframe'] assert provider.scope == SingletonScope assert isinstance(graph.get('view.timerframe'), TimerFrame)
def test_timer_tab(self, graph, config, session): graph.register_instance("tomate.config", config) scan_to_graph(["tomate_gtk.dialogs.preference"], graph) assert "view.preference.duration" in graph.providers provider = graph.providers["view.preference.duration"] assert provider.scope == SingletonScope assert isinstance(graph.get("view.preference.duration"), TimerTab)
def window(bus, config, graph, session) -> Window: graph.register_instance("focusyn.bus", bus) graph.register_instance("focusyn.config", config) graph.register_instance("focusyn.session", session) namespaces = [ "focusyn.ui", "focusyn.pomodoro.plugin", ] scan_to_graph(namespaces, graph) return graph.get("focusyn.ui.view")
def session_button(bus, graph, session, shortcut_engine) -> SessionButton: graph.register_instance("focusyn.bus", bus) graph.register_instance("focusyn.session", session) graph.register_instance("focusyn.ui.shortcut", shortcut_engine) scan_to_graph(["focusyn.ui.widgets.session_button"], graph) # gtk shortcuts binds leave beyond the scope shortcut_engine.disconnect(SessionButton.POMODORO_SHORTCUT) shortcut_engine.disconnect(SessionButton.SHORT_BREAK_SHORTCUT) shortcut_engine.disconnect(SessionButton.LONG_BREAK_SHORTCUT) return graph.get("focusyn.ui.taskbutton")
def test_trayicon_module(graph): scan_to_graph(['tomate_gtk.widgets.menu'], graph) assert 'trayicon.menu' in graph.providers provider = graph.providers['view.menu'] assert provider.scope == SingletonScope graph.register_instance('tomate.view', Mock()) assert isinstance(graph.get('trayicon.menu'), TrayIconMenu)
def test_taskbutton_module(graph, mocker): scan_to_graph(['tomate_gtk.widgets.taskbutton'], graph) assert 'view.taskbutton' in graph.providers provider = graph.providers['view.taskbutton'] assert provider.scope == SingletonScope graph.register_factory('tomate.session', mocker.Mock) assert isinstance(graph.get('view.taskbutton'), TaskButton)
def test_taskbutton_module(graph): from tomate_gtk.widgets.infobar import InfoBar scan_to_graph(['tomate_gtk.widgets.infobar'], graph) assert SPECIFICATION in graph.providers provider = graph.providers[SPECIFICATION] assert provider.scope == SingletonScope assert isinstance(graph.get(SPECIFICATION), InfoBar)
def test_module(graph, subject): spec = "view.countdown" scan_to_graph(["tomate_gtk.widgets.countdown"], graph) assert spec in graph.providers provider = graph.providers[spec] assert provider.scope == SingletonScope assert isinstance(graph.get(spec), Countdown)
def test_module(graph, mocker): scan_to_graph(['tomate_gtk.widgets.appmenu'], graph) assert 'view.appmenu' in graph.providers provider = graph.providers['view.appmenu'] assert provider.scope == SingletonScope graph.register_instance('view.menu', mocker.Mock(widget=Gtk.Menu())) assert isinstance(graph.get('view.appmenu'), Appmenu)
def test_module(graph, session): spec = "view.taskbutton" scan_to_graph(["tomate_gtk.widgets.task_button"], graph) graph.register_instance("tomate.session", session) assert spec in graph.providers provider = graph.providers[spec] assert provider.scope == SingletonScope assert isinstance(graph.get(spec), TaskButton)
def test_module(graph, mocker, shortcut_manager): spec = "view.shortcut" scan_to_graph(["tomate_gtk.shortcut"], graph) assert spec in graph.providers graph.register_instance("tomate.config", mocker.Mock()) provider = graph.providers[spec] assert provider.scope == SingletonScope assert isinstance(graph.get(spec), shortcut_manager.__class__)
def test_module(self, about, bus, preference, graph, shortcut_engine): graph.register_instance("tomate.bus", bus) graph.register_instance("tomate.ui.about", about) graph.register_instance("tomate.ui.preference", preference) graph.register_instance("tomate.ui.shortcut", shortcut_engine) namespaces = ["tomate.ui.widgets.headerbar"] scan_to_graph(namespaces, graph) instance = graph.get("tomate.ui.headerbar.menu") assert isinstance(instance, HeaderBarMenu) assert instance is graph.get("tomate.ui.headerbar.menu")
def test_module(graph, mock_config): spec = "tomate.plugin" scan_to_graph([spec], graph) assert spec in graph.providers provider = graph.providers[spec] assert provider.scope == SingletonScope graph.register_instance("tomate.config", mock_config) assert isinstance(graph.get(spec), PluginManager)
def test_preference(self, graph, config, lazy_proxy, plugin_manager): graph.register_instance("tomate.plugin", plugin_manager) graph.register_instance("tomate.config", config) graph.register_instance("tomate.proxy", lazy_proxy) scan_to_graph(["tomate_gtk.dialogs.preference"], graph) assert "view.preference" in graph.providers provider = graph.providers["view.preference"] assert provider.scope == SingletonScope assert isinstance(graph.get("view.preference"), PreferenceDialog)
def test_extension_tab(self, graph, session, config, plugin_manager, lazy_proxy): graph.register_instance("tomate.plugin", plugin_manager) graph.register_instance("tomate.config", config) graph.register_instance("tomate.proxy", lazy_proxy) scan_to_graph(["tomate_gtk.dialogs.preference"], graph) assert "view.preference.extension" in graph.providers provider = graph.providers["view.preference.extension"] assert provider.scope == SingletonScope assert isinstance(graph.get("view.preference.extension"), ExtensionTab)
def test_toolbar_module(graph): scan_to_graph(['tomate_gtk.widgets.toolbar'], graph) assert 'view.toolbar' in graph.providers graph.register_instance('tomate.menu', Gtk.Menu()) graph.register_instance('view.menu', Mock(widget=Gtk.Menu())) graph.register_instance('tomate.session', Mock()) graph.register_factory('view.appmenu', Appmenu) provider = graph.providers['view.toolbar'] assert provider.scope == SingletonScope assert isinstance(graph.get('view.toolbar'), Toolbar)
def test_module(graph, mocker): spec = "tomate.timer" scan_to_graph([spec], graph) assert spec in graph.providers provider = graph.providers[spec] assert provider.scope == SingletonScope graph.register_factory("tomate.events.timer", mocker.Mock) assert isinstance(graph.get(spec), Timer)
def test_module(self, graph, mock_view): specification = "trayicon.menu" graph.register_instance("tomate.view", mock_view) scan_to_graph(["tomate_gtk.widgets.menu"], graph) assert specification in graph.providers provider = graph.providers[specification] assert provider.scope == SingletonScope assert isinstance(graph.get(specification), TrayIconMenu)
def test_module(graph): spec = "tomate.config" scan_to_graph([spec], graph) assert spec in graph.providers provider = graph.providers[spec] assert provider.scope == SingletonScope graph.register_instance("tomate.events.setting", Mock()) assert isinstance(graph.get(spec), Config)
def main(): try: options = parse_options() setup_logging(options) scan_to_graph(["focusyn"], graph) app = Application.from_graph(graph) app.Run() if app.IsRunning(): Gdk.notify_startup_complete() except Exception as ex: logger.error(ex, exc_info=True) raise ex
def test_scan_to_graph(self): graph = Graph() scan_to_graph( ['tests.scanning.testmodule'], graph, ignore=['tests.scanning.testmodule.ignoredsubmodule'] ) self._validate_providers(graph.providers) from . import testmodule graph = Graph() scan_to_graph( [testmodule], graph, ignore=['tests.scanning.testmodule.ignoredsubmodule'] ) self._validate_providers(graph.providers)