예제 #1
0
def test_client_status_bad():
    status_response = "FOO"
    with patch('compoundpi.client.CompoundPiServerList.transact') as l, \
            patch('compoundpi.client.CompoundPiDownloadServer'):
        l.return_value = {
            compoundpi.client.IPv4Address('192.168.0.1'): status_response,
            compoundpi.client.IPv4Address('192.168.0.2'): status_response,
            }
        client = compoundpi.client.CompoundPiClient()
        with pytest.raises(CompoundPiTransactionFailed) as excinfo:
            client.status()
            assert len(excinfo.value.errors) == 2
            assert isinstance(excinfo.value.errors[0], CompoundPiInvalidResponse)
            assert isinstance(excinfo.value.errors[1], CompoundPiInvalidResponse)
예제 #2
0
def test_client_status_ok():
    status_response = """\
RESOLUTION 1280,720
FRAMERATE 30
AWB auto,14/10,15/10
AGC auto,4,1
EXPOSURE auto,33.200
ISO 100
METERING spot
BRIGHTNESS 50
CONTRAST 25
SATURATION 15
EV 0
FLIP 1,0
DENOISE 0
TIMESTAMP 1000.0
FILES 0
"""
    status_struct = compoundpi.client.CompoundPiStatus(
        resolution=compoundpi.client.Resolution(1280, 720),
        framerate=Fraction(30, 1),
        awb_mode='auto',
        awb_red=Fraction(14, 10),
        awb_blue=Fraction(15, 10),
        agc_mode='auto',
        agc_analog=Fraction(4, 1),
        agc_digital=Fraction(1, 1),
        exposure_mode='auto',
        exposure_speed=33.2,
        ev=0,
        iso=100,
        metering_mode='spot',
        brightness=50,
        contrast=25,
        saturation=15,
        hflip=True,
        vflip=False,
        denoise=False,
        timestamp=dt.datetime.fromtimestamp(1000.0),
        files=0
        )
    with patch('compoundpi.client.CompoundPiServerList.transact') as l, \
            patch('compoundpi.client.CompoundPiDownloadServer'):
        l.return_value = {
            compoundpi.client.IPv4Address('192.168.0.1'): status_response,
            compoundpi.client.IPv4Address('192.168.0.2'): status_response,
            }
        client = compoundpi.client.CompoundPiClient()
        assert client.status() == {
            compoundpi.client.IPv4Address('192.168.0.1'): status_struct,
            compoundpi.client.IPv4Address('192.168.0.2'): status_struct,
            }
        l.assert_called_once_with('STATUS', None)