コード例 #1
0
ファイル: test_session.py プロジェクト: skalanux/focusyn
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")
コード例 #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)
コード例 #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")
コード例 #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)
コード例 #5
0
ファイル: test_event.py プロジェクト: sebix/tomate
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",
    ])
コード例 #6
0
ファイル: test_plugin.py プロジェクト: eliostvs/tomate-gtk
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")
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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
コード例 #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)
コード例 #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)
コード例 #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")
コード例 #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")
コード例 #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)
コード例 #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)
コード例 #17
0
ファイル: test_infobar.py プロジェクト: jpeller/tomate-gtk
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)
コード例 #18
0
ファイル: test_countdown.py プロジェクト: Sts0mrg0/tomate-gtk
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)
コード例 #19
0
ファイル: test_appmenu.py プロジェクト: jpeller/tomate-gtk
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)
コード例 #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)
コード例 #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__)
コード例 #22
0
ファイル: test_headerbar.py プロジェクト: eliostvs/tomate-gtk
    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")
コード例 #23
0
ファイル: test_plugin.py プロジェクト: sebix/tomate
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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #29
0
ファイル: test_config.py プロジェクト: sebix/tomate
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)
コード例 #30
0
ファイル: main.py プロジェクト: skalanux/focusyn
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
コード例 #31
0
ファイル: scanning_tests.py プロジェクト: msiedlarek/wiring
    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)