Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
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",
    ])
Ejemplo n.º 6
0
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")
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
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")
Ejemplo n.º 14
0
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")
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
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)
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
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)
Ejemplo n.º 21
0
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__)
Ejemplo n.º 22
0
    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")
Ejemplo n.º 23
0
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)
Ejemplo n.º 24
0
    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)
Ejemplo n.º 25
0
    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)
Ejemplo n.º 26
0
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)
Ejemplo n.º 27
0
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)
Ejemplo n.º 28
0
    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)
Ejemplo n.º 29
0
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)
Ejemplo n.º 30
0
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
Ejemplo n.º 31
0
    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)