Exemple #1
0
def test_capture_noprepare(jpeg, camera):
    camera._run.side_effect = (
        chdkcamera.CHDKPTPException('dev not in rec mode'), None)
    with mock.patch.object(camera, 'prepare_capture') as prepare:
        camera.capture(Path('/tmp/000.jpg'))
        assert prepare.call_count == 1
        assert camera._run.call_count == 2
Exemple #2
0
def test_acquire_focus(sleep, camera):
    camera._run.side_effect = chdkcamera.CHDKPTPException()
    camera._execute_lua.side_effect = (None, None, None, None, None, 300)
    assert camera._acquire_focus() == 300
    assert camera._run.call_count == 1
Exemple #3
0
def test_capture_error(camera):
    camera._run.side_effect = chdkcamera.CHDKPTPException('foobar')
    with pytest.raises(chdkcamera.CHDKPTPException) as exc:
        camera.capture(Path('/tmp/000.jpg'))
        assert exc is camera._run.side_effect
Exemple #4
0
def test_prepare_capture_withrec(camera):
    camera._run.side_effect = chdkcamera.CHDKPTPException()
    camera.prepare_capture(Path('/tmp/foo.jpg'))
    camera._execute_lua.assert_any_call('enter_alt()')
    camera._run.assert_any_call('rec')
Exemple #5
0
def test_capture_error(camera):
    camera._device.shoot.side_effect = chdkcamera.CHDKPTPException('foobar')
    camera._device.mode = 'rec'
    with pytest.raises(chdkcamera.CHDKPTPException) as exc:
        camera.capture(mock.MagicMock())
        assert exc is camera._device.shoot.side_effect