Пример #1
0
def test_cli_benchmark(monkeypatch, capsys, qapp, qtbot):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    monkeypatch.setattr(QApplication, 'exit', lambda x: 1)
    windows = typhos_cli(['ophyd.sim.SynAxis[]', '--benchmark', 'flat_soft'])
    qtbot.addWidget(windows[0])
    output = capsys.readouterr()
    assert 'add_device' in output.out
Пример #2
0
def test_cli_profile_modules(monkeypatch, capsys, qapp, qtbot):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    window = typhos_cli(
        ['ophyd.sim.SynAxis[]', '--profile-modules', 'typhos.suite'])
    qtbot.addWidget(window)
    output = capsys.readouterr()
    assert 'add_device' in output.out
Пример #3
0
def test_cli_class(qtbot, klass, name, happi_cfg):
    window = typhos_cli([klass])
    qtbot.addWidget(window)
    assert window.isVisible()

    suite = window.centralWidget()
    assert name == suite.devices[0].name

    for dev in suite.devices:
        conftest.clear_handlers(dev)
Пример #4
0
def test_cli_class(monkeypatch, qapp, qtbot, klass, name, happi_cfg):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    window = typhos_cli([klass])
    qtbot.addWidget(window)
    assert window.isVisible()

    suite = window.centralWidget()
    assert name == suite.devices[0].name

    for dev in suite.devices:
        conftest.clear_handlers(dev)
Пример #5
0
def test_cli_profile_output(capsys, qtbot):
    path_obj = conftest.MODULE_PATH / 'artifacts' / 'prof'
    if not path_obj.parent.exists():
        path_obj.parent.mkdir(parents=True)
    window = typhos_cli(
        ['ophyd.sim.SynAxis[]', '--profile-output',
         str(path_obj)])
    qtbot.addWidget(window)
    output = capsys.readouterr()
    assert 'add_device' not in output.out
    assert path_obj.exists()
Пример #6
0
def test_cli_profile_output(monkeypatch, capsys, qapp, qtbot):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    path_obj = conftest.MODULE_PATH / 'artifacts' / 'prof'
    if not path_obj.parent.exists():
        path_obj.parent.mkdir(parents=True)
    window = typhos_cli(
        ['ophyd.sim.SynAxis[]', '--profile-output',
         str(path_obj)])
    qtbot.addWidget(window)
    output = capsys.readouterr()
    assert 'add_device' not in output.out
    assert path_obj.exists()
Пример #7
0
def test_cli_stylesheet(monkeypatch, qapp, qtbot, happi_cfg):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    with open('test.qss', 'w+') as handle:
        handle.write(
            "TyphosDeviceDisplay {qproperty-force_template: 'test.ui'}")
    style = qapp.styleSheet()
    window = typhos_cli(
        ['test_motor', '--stylesheet', 'test.qss', '--happi-cfg', happi_cfg])
    qtbot.addWidget(window)
    suite = window.centralWidget()
    dev_display = suite.get_subdisplay(suite.devices[0])
    assert dev_display.force_template == 'test.ui'
    qapp.setStyleSheet(style)
    os.remove('test.qss')
Пример #8
0
def test_cli_stylesheet(qapp, qtbot, happi_cfg):
    with open('test.qss', 'w+') as handle:
        handle.write(
            "TyphosDeviceDisplay {qproperty-force_template: 'test.ui'}")
    try:
        style = qapp.styleSheet()
        window = typhos_cli([
            'test_motor', '--stylesheet', 'test.qss', '--happi-cfg', happi_cfg
        ])
        qtbot.addWidget(window)
        suite = window.centralWidget()
        dev_display = suite.get_subdisplay(suite.devices[0])
        assert dev_display.force_template == 'test.ui'
        qapp.setStyleSheet(style)
    finally:
        os.remove('test.qss')
Пример #9
0
def test_cli_class_invalid(qtbot):
    window = typhos_cli(["non.Valid.ClassName[]"])
    assert window is None
Пример #10
0
def test_cli_no_entry(monkeypatch, qtbot, happi_cfg):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    window = typhos_cli(['--happi-cfg', happi_cfg])
    qtbot.addWidget(window)
    assert window.isVisible()
    assert window.centralWidget().devices == []
Пример #11
0
def test_cli_bad_entry(qtbot, happi_cfg):
    window = typhos_cli(['no_motor', '--happi-cfg', happi_cfg])
    assert window is None
Пример #12
0
def test_cli_no_entry(qtbot, happi_cfg):
    window = typhos_cli(['--happi-cfg', happi_cfg])
    qtbot.addWidget(window)
    assert window.isVisible()
    assert window.centralWidget().devices == []
Пример #13
0
def test_cli_version(capsys):
    typhos_cli(['--version'])
    readout = capsys.readouterr()
    assert typhos.__version__ in readout.out
Пример #14
0
def test_cli_benchmark(capsys, qtbot):
    windows = typhos_cli(['ophyd.sim.SynAxis[]', '--benchmark', 'flat_soft'])
    qtbot.addWidget(windows[0])
    output = capsys.readouterr()
    assert 'add_device' in output.out
Пример #15
0
def test_cli_profile_modules(capsys, qtbot):
    window = typhos_cli(
        ['ophyd.sim.SynAxis[]', '--profile-modules', 'typhos.suite'])
    qtbot.addWidget(window)
    output = capsys.readouterr()
    assert 'add_device' in output.out
Пример #16
0
def test_cli_happi_cfg(monkeypatch, qtbot, happi_cfg):
    monkeypatch.setattr(QApplication, 'exec_', lambda x: 1)
    window = typhos_cli(['test_motor', '--happi-cfg', happi_cfg])
    qtbot.addWidget(window)
    assert window.isVisible()
    assert 'test_motor' == window.centralWidget().devices[0].name
Пример #17
0
def test_cli_happi_cfg(qtbot, happi_cfg):
    window = typhos_cli(['test_motor', '--happi-cfg', happi_cfg])
    qtbot.addWidget(window)
    assert window.isVisible()
    assert 'test_motor' == window.centralWidget().devices[0].name