コード例 #1
0
def test_video(monkeypatch, setup_test):
    c = Camera(sw_cam=True)
    c.file_by_date = False
    with freeze_time(parse("2000-01-01 12:00:00")) as fdt:
        global FDT
        FDT = fdt
        real_sleep = time.sleep
        monkeypatch.setattr(time, 'sleep', sleepless)
        # start normally
        c.mode_button.value = ON
        c._interval = timedelta(seconds=60)

        while dt.now() < today_at(13):
            c.run(1)
            fdt.tick(timedelta(seconds=1))

        # switch to video mode
        c.mode_button.value = VIDEO
        vtd = threading.Thread(target=video_server, args=(c, fdt), daemon=True)
        vtd.start()
        real_sleep(3)
        c.mode_button.value = OFF
        vtd.join()
        real_sleep(1)

        # switch to video mode agina : ok
        c.mode_button.value = VIDEO
        vtd = threading.Thread(target=video_server, args=(c, fdt), daemon=True)
        vtd.start()
        real_sleep(3)
        c.mode_button.value = OFF
        vtd.join()
コード例 #2
0
ファイル: test_camera.py プロジェクト: brettbeeson/tmv
def check_test_fake2(monkeypatch, setup_test):
    s = 3
    c = Camera(sw_cam=True)
    c.tmv_root = "./test_fake2/"
    c.file_by_date = False
    c.interval = timedelta(seconds=1)
    c.active_timer = ActiveTimes.factory(dt.now().astimezone().time(
    ), (dt.now() + timedelta(seconds=s)).astimezone().time(), c)
    c.camera_inactive_action = CameraInactiveAction.EXCEPTION
    with pytest.raises(PowerOff):
        c.run()
    assert len(c.recent_images) == s + 1  # fencepost
    images = glob(os.path.join(c.tmv_root, "*.jpg"))
    assert len(images) == s + 1  # fencepost
コード例 #3
0
ファイル: test_camera.py プロジェクト: brettbeeson/tmv
def test_config(monkeypatch, setup_test):
    with freeze_time(parse("2000-01-01 00:00:00")) as fdt:
        global FDT
        FDT = fdt
        c = Camera(sw_cam=True)

        c.tmv_root = "./test_config/"
        cf = """
        [location]
            city = "Brisbane"
        [camera]
            off = 07:00:00
            on = 18:00:00
        
        [camera.picam.LIGHT]
            id = "Custom day config at 800"
            iso = 800
            exposure_mode = "auto"
            resolution = "800x600"

        [camera.picam.DIM]
            id = "CUSTOM-DIM"
            framerate = 1
            iso = 0
            exposure_mode = "night"
            resolution = "800x600"

        [camera.picam.DARK]
            id = "CUSTOM-NIGHTY"
            framerate = 1
            iso = 1600
            shutter_speed = 1000000
            exposure_mode = "verylong"
            resolution = "800x600"
        """
        c.configs(cf)
        # default
        assert c.picam[LightLevel.LIGHT.name]['exposure_mode'] == 'auto'
        assert c.picam[LightLevel.LIGHT.name]['resolution'] == '800x600'
        # new one
        assert c.picam[LightLevel.LIGHT.name]['iso'] == 800
        c._camera = FakePiCamera()
        # fake sleeping
        monkeypatch.setattr(time, 'sleep', sleepless)
        c.run(3)
        # should have clicked over to DARK. Configured a special iso for DARK in toml.
        assert c.picam[c.light_sensor.level.name]['iso'] == 1600
        c.run(1)
コード例 #4
0
def video_server(c: Camera, fdt):
    while c.mode_button.value != VIDEO:
        c.run(1)