Пример #1
0
def test_load_attached_within_tmux_detached(server, monkeypatch):
    # Load a session and attach from within tmux
    monkeypatch.setenv('TMUX', "/tmp/tmux-1234/default,123,0")

    switch_client_mock = MagicMock()
    switch_client_mock.return_value.stderr = None

    monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)

    yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
    sconfig = kaptan.Kaptan(handler='yaml')
    sconfig = sconfig.import_config(yaml_config).get()

    builder = WorkspaceBuilder(sconf=sconfig, server=server)

    _load_attached(builder, True)

    assert builder.session.switch_client.call_count == 1
Пример #2
0
def test_load_attached_detached(server, monkeypatch):
    # Load a session but don't attach
    monkeypatch.delenv('TMUX', raising=False)

    attach_session_mock = MagicMock()
    attach_session_mock.return_value.stderr = None

    monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)

    yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
    sconfig = kaptan.Kaptan(handler='yaml')
    sconfig = sconfig.import_config(yaml_config).get()

    builder = WorkspaceBuilder(sconf=sconfig, server=server)

    _load_attached(builder, True)

    assert builder.session.attach_session.call_count == 0