예제 #1
0
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
예제 #2
0
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)