def test_creation():
    new_ref = s.GNSSSignal(sat=8, band=0, constellation=0)
    sids = [
        s.GNSSSignal(sat=2, band=0, constellation=0),
        s.GNSSSignal(sat=1, band=0, constellation=0),
        s.GNSSSignal(sat=3, band=0, constellation=0),
        s.GNSSSignal(sat=4, band=0, constellation=0)
    ]
    sm = sat.SatsManagement(sids=sids)
    assert sm.num_sats
    assert sm.sids[0]['sat'] == 2
    assert sm.sids[1]['sat'] == 1
    assert sm.sids[2]['sat'] == 3
    assert sm.sids[3]['sat'] == 4
    assert not sm._print()
    assert not sm._print_short()
    sdiffs = [
        o.SingleDiff(sid={
            'sat': 1,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=1),
        o.SingleDiff(sid={
            'sat': 2,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=5),
        o.SingleDiff(sid={
            'sat': 3,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=10)
    ]
    # TODO (Buro): Check outputs!
    assert sm.rebase(sdiffs)
    assert not sm.update(sdiffs)
def test_bad_measurements():
    sids = [
        s.GNSSSignal(sat=1, band=0, constellation=0),
        s.GNSSSignal(sat=2, band=0, constellation=0),
        s.GNSSSignal(sat=3, band=0, constellation=0),
        s.GNSSSignal(sat=5, band=0, constellation=0),
        s.GNSSSignal(sat=6, band=0, constellation=0)
    ]
    float_sats = sat.SatsManagement(sids=sids)
    sids = [
        s.GNSSSignal(sat=3, band=0, constellation=0),
        s.GNSSSignal(sat=1, band=0, constellation=0),
        s.GNSSSignal(sat=2, band=0, constellation=0),
        s.GNSSSignal(sat=5, band=0, constellation=0),
        s.GNSSSignal(sat=6, band=0, constellation=0)
    ]
    amb_sats_init = sat.SatsManagement(sids=sids)
    test = a.AmbiguityTest(sats=float_sats)
    sdiffs = [
        o.SingleDiff(sid={
            'sat': 1,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 2,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 3,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 4,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 5,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 6,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0)
    ]
def test_update_sats_same_sats():
    sids = [
        s.GNSSSignal(sat=3, band=0, constellation=0),
        s.GNSSSignal(sat=1, band=0, constellation=0),
        s.GNSSSignal(sat=2, band=0, constellation=0),
        s.GNSSSignal(sat=4, band=0, constellation=0)
    ]
    sm = sat.SatsManagement(sids=sids)
    test = a.AmbiguityTest(sats=sm)
    sdiffs = [
        o.SingleDiff(sid={
            'sat': 1,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 2,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 3,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0),
        o.SingleDiff(sid={
            'sat': 4,
            'band': 0,
            'constellation': 0
        },
                     pseudorange=0,
                     sat_pos=(0, 0, 0),
                     sat_vel=(0, 0, 0),
                     carrier_phase=0,
                     raw_doppler=0,
                     doppler=0,
                     snr=0)
    ]
    assert not test.ambiguity_update_sats(sdiffs, None, None, None, None,
                                          False)
    assert test.sats['sids'][0]['sat'] == 3
    assert test.sats['sids'][1]['sat'] == 1
    assert test.sats['sids'][2]['sat'] == 2
    assert test.sats['sids'][3]['sat'] == 4