Beispiel #1
0
def test_join_grid_emit_update_progress_signal(monkeypatch, qtbot, tmpdir):
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir',
                        str(tmpdir.mkdir('config_dir')))
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())
    sr = SetupRunner([])
    settings = {'nickname': 'TestGrid'}
    with qtbot.wait_signal(sr.update_progress) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == ["Connecting to TestGrid..."]
Beispiel #2
0
def test_join_grid_emit_got_icon_signal_icon_base64(monkeypatch, qtbot,
                                                    tmpdir):
    tmp_config_dir = str(tmpdir.mkdir('config_dir'))
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir', tmp_config_dir)
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())
    sr = SetupRunner([])
    settings = {'nickname': 'TestGrid', 'icon_base64': 'dGVzdDEyMzQ1'}
    with qtbot.wait_signal(sr.got_icon) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == [os.path.join(tmp_config_dir, '.icon.tmp')]
Beispiel #3
0
def test_join_grid_emit_got_icon_signal_nickname_least_authority_s4(
        monkeypatch, qtbot, tmpdir):
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir',
                        str(tmpdir.mkdir('config_dir')))
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())
    sr = SetupRunner([])
    settings = {'nickname': 'Least Authority S4'}
    with qtbot.wait_signal(sr.got_icon) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == [resource('leastauthority.com.icon')]
Beispiel #4
0
def test_join_grid_no_emit_icon_signal_exception(monkeypatch, qtbot, tmpdir):
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir',
                        str(tmpdir.mkdir('config_dir')))
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())
    monkeypatch.setattr('treq.get', fake_get)
    monkeypatch.setattr('treq.content', lambda _: b'0')
    monkeypatch.setattr('gridsync.setup.SetupRunner.fetch_icon',
                        MagicMock(side_effect=Exception()))
    sr = SetupRunner([])
    settings = {'nickname': 'TestGrid', 'icon_url': 'https://gridsync.io/icon'}
    with qtbot.assert_not_emitted(sr.got_icon):
        yield sr.join_grid(settings)
Beispiel #5
0
def test_join_grid_emit_got_icon_signal_icon_url(monkeypatch, qtbot, tmpdir):
    tmp_config_dir = str(tmpdir.mkdir('config_dir'))
    os.makedirs(os.path.join(tmp_config_dir, 'TestGrid'))
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir', tmp_config_dir)
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())
    monkeypatch.setattr('treq.get', fake_get)
    monkeypatch.setattr('treq.content', lambda _: b'0')
    sr = SetupRunner([])
    settings = {'nickname': 'TestGrid', 'icon_url': 'https://gridsync.io/icon'}
    with qtbot.wait_signal(sr.got_icon) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == [os.path.join(tmp_config_dir, '.icon.tmp')]
Beispiel #6
0
def test_join_grid_emit_got_icon_signal_icon_base64(
    monkeypatch, qtbot, tmpdir
):
    tmp_config_dir = str(tmpdir.mkdir("config_dir"))
    monkeypatch.setattr(
        "gridsync.setup.select_executable", lambda: (None, None)
    )
    monkeypatch.setattr("gridsync.setup.config_dir", tmp_config_dir)
    monkeypatch.setattr("gridsync.setup.Tahoe", MagicMock())
    sr = SetupRunner([])
    settings = {"nickname": "TestGrid", "icon_base64": "dGVzdDEyMzQ1"}
    with qtbot.wait_signal(sr.got_icon) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == [os.path.join(tmp_config_dir, ".icon.tmp")]
Beispiel #7
0
def test_join_grid_storage_servers(monkeypatch, tmpdir):
    monkeypatch.setattr('gridsync.setup.select_executable', lambda:
                        (None, None))
    monkeypatch.setattr('gridsync.setup.config_dir',
                        str(tmpdir.mkdir('config_dir')))
    monkeypatch.setattr('gridsync.setup.Tahoe', MagicMock())

    def fake_add_storage_servers(*_):
        assert True

    monkeypatch.setattr('gridsync.tahoe.Tahoe.add_storage_servers',
                        fake_add_storage_servers)
    sr = SetupRunner([])
    settings = {'nickname': 'TestGrid', 'storage': {'test': 'test'}}
    yield sr.join_grid(settings)
Beispiel #8
0
def test_join_grid_emit_got_icon_signal_icon_url(monkeypatch, qtbot, tmpdir):
    tmp_config_dir = str(tmpdir.mkdir("config_dir"))
    os.makedirs(os.path.join(tmp_config_dir, "TestGrid"))
    monkeypatch.setattr(
        "gridsync.setup.select_executable", lambda: (None, None)
    )
    monkeypatch.setattr("gridsync.setup.config_dir", tmp_config_dir)
    monkeypatch.setattr("gridsync.setup.Tahoe", MagicMock())
    monkeypatch.setattr("treq.get", fake_get)
    monkeypatch.setattr("treq.content", lambda _: b"0")
    sr = SetupRunner([])
    settings = {"nickname": "TestGrid", "icon_url": "https://gridsync.io/icon"}
    with qtbot.wait_signal(sr.got_icon) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == [os.path.join(tmp_config_dir, ".icon.tmp")]
Beispiel #9
0
def test_join_grid_emit_update_progress_signal_via_tor(
    monkeypatch, qtbot, tmpdir
):
    monkeypatch.setattr(
        "gridsync.setup.select_executable", lambda: (None, None)
    )
    monkeypatch.setattr(
        "gridsync.setup.config_dir", str(tmpdir.mkdir("config_dir"))
    )
    monkeypatch.setattr("gridsync.setup.Tahoe", MagicMock())
    sr = SetupRunner([], use_tor=True)
    settings = {"nickname": "TestGrid"}
    with qtbot.wait_signal(sr.update_progress) as blocker:
        yield sr.join_grid(settings)
    assert blocker.args == ["Connecting to TestGrid via Tor..."]
Beispiel #10
0
def test_join_grid_storage_servers(monkeypatch, tmpdir):
    monkeypatch.setattr(
        "gridsync.setup.select_executable", lambda: (None, None)
    )
    monkeypatch.setattr(
        "gridsync.setup.config_dir", str(tmpdir.mkdir("config_dir"))
    )
    monkeypatch.setattr("gridsync.setup.Tahoe", MagicMock())

    def fake_add_storage_servers(*_):
        assert True

    monkeypatch.setattr(
        "gridsync.tahoe.Tahoe.add_storage_servers", fake_add_storage_servers
    )
    sr = SetupRunner([])
    settings = {"nickname": "TestGrid", "storage": {"test": "test"}}
    yield sr.join_grid(settings)
Beispiel #11
0
def test_join_grid_no_emit_icon_signal_exception(monkeypatch, qtbot, tmpdir):
    monkeypatch.setattr(
        "gridsync.setup.select_executable", lambda: (None, None)
    )
    monkeypatch.setattr(
        "gridsync.setup.config_dir", str(tmpdir.mkdir("config_dir"))
    )
    monkeypatch.setattr("gridsync.setup.Tahoe", MagicMock())
    monkeypatch.setattr("treq.get", fake_get)
    monkeypatch.setattr("treq.content", lambda _: b"0")
    monkeypatch.setattr(
        "gridsync.setup.SetupRunner.fetch_icon",
        MagicMock(side_effect=Exception()),
    )
    sr = SetupRunner([])
    settings = {"nickname": "TestGrid", "icon_url": "https://gridsync.io/icon"}
    with qtbot.assert_not_emitted(sr.got_icon):
        yield sr.join_grid(settings)