示例#1
0
    def start(self) -> None:
        self.shell.processes.start(serial.maintain_serial_devices(self.shell))

        gpsstate = gpstime.GPSTimeState()
        self.shell.processes.start(gpstime.gps_time_sync(self.shell, gpsstate))
        self.shell.processes.start(gpstime.clock_indicator(self.shell.screen, gpsstate))

        simfile = os.environ.get("OVSHELL_CORE_SIMULATE_DEVICE")
        if simfile:
            devsim.run_simulated_device(self.shell, simfile)

        self.shell.processes.start(devindicators.show_device_indicators(self.shell))
async def test_nodevs(ovshell: testing.OpenVarioShellStub, monkeypatch) -> None:
    # GIVEN
    monkeypatch.setattr("ovshell_core.devindicators.DEVICE_POLL_INTERVAL", 0.01)

    # WHEN
    task = asyncio.create_task(devindicators.show_device_indicators(ovshell))
    await asyncio.sleep(0)

    # THEN
    assert ovshell.screen.stub_list_indicators() == []

    task.cancel()
    await asyncio.sleep(0)
    assert task.cancelled()
async def test_dev_indicators(ovshell: testing.OpenVarioShellStub, monkeypatch) -> None:
    # GIVEN
    monkeypatch.setattr("ovshell_core.devindicators.DEVICE_POLL_INTERVAL", 0.01)
    dev = SampleDevice("sample", "Sample")
    ovshell.devices.register(dev)

    # WHEN
    task = asyncio.create_task(devindicators.show_device_indicators(ovshell))
    await asyncio.sleep(0)

    # THEN
    ind = ovshell.screen.stub_get_indicator("sample")
    assert ind is not None
    assert ind.location == api.IndicatorLocation.RIGHT

    task.cancel()
    await asyncio.sleep(0)
    assert task.cancelled()
示例#4
0
async def test_remove_indicators(ovshell: testing.OpenVarioShellStub,
                                 monkeypatch) -> None:
    # GIVEN
    monkeypatch.setattr("ovshell_core.devindicators.DEVICE_POLL_INTERVAL",
                        0.01)
    ovshell.devices.register(SampleDevice("sample1", "Sample 1"))
    ovshell.devices.register(SampleDevice("sample2", "Sample 2"))

    task = asyncio.create_task(devindicators.show_device_indicators(ovshell))
    await asyncio.sleep(0)
    assert len(ovshell.screen.stub_list_indicators()) == 2

    # WHEN
    ovshell.devices.stub_remove_device("sample1")
    await asyncio.sleep(0.02)

    # THEN
    assert len(ovshell.screen.stub_list_indicators()) == 1
    ind = ovshell.screen.stub_get_indicator("sample")
    assert ind is None

    task.cancel()
    await asyncio.sleep(0)
    assert task.cancelled()