예제 #1
0
def test_geoinfo_polygons_bad_order(good_xml):
    root = copy_xml(good_xml['with_ns'])
    root.append(
        make_elem(
            'GeoInfo',
            namespace=good_xml['nsmap']['ns'],
            children=[
                make_elem(
                    'Polygon',
                    size='3',
                    namespace=good_xml['nsmap']['ns'],
                    children=[
                        make_elem(
                            'Vertex',
                            index='1',
                            namespace=good_xml['nsmap']['ns'],
                            children=[
                                make_elem('Lat',
                                          0.0,
                                          namespace=good_xml['nsmap']['ns']),
                                make_elem('Lon',
                                          0.0,
                                          namespace=good_xml['nsmap']['ns']),
                            ]),
                        make_elem(
                            'Vertex',
                            index='2',
                            namespace=good_xml['nsmap']['ns'],
                            children=[
                                make_elem('Lat',
                                          0.0,
                                          namespace=good_xml['nsmap']['ns']),
                                make_elem('Lon',
                                          1.0,
                                          namespace=good_xml['nsmap']['ns']),
                            ]),
                        make_elem(
                            'Vertex',
                            index='3',
                            namespace=good_xml['nsmap']['ns'],
                            children=[
                                make_elem('Lat',
                                          1.0,
                                          namespace=good_xml['nsmap']['ns']),
                                make_elem('Lon',
                                          1.0,
                                          namespace=good_xml['nsmap']['ns']),
                            ]),
                    ])
            ]))

    cphd_con = CphdConsistency(root,
                               pvps=None,
                               header=None,
                               filename=None,
                               schema=DEFAULT_SCHEMA,
                               check_signal_data=False)

    cphd_con.check('check_geoinfo_polygons')
    assert len(cphd_con.failures()) > 0
예제 #2
0
def test_antenna_bad_antpats_count(good_xml):
    root = copy_xml(good_xml['with_ns'])
    antenna_node = root.find('./ns:Antenna', namespaces=good_xml['nsmap'])
    antenna_node.xpath('./ns:NumAntPats', namespaces=good_xml['nsmap'])[-1].text += '2'
    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_antenna')
    assert len(cphd_con.failures()) > 0
예제 #3
0
def test_antenna_non_matching_acfids(good_xml):
    root = copy_xml(good_xml['with_ns'])
    antenna_node = root.find('./ns:Antenna', namespaces=good_xml['nsmap'])
    antenna_node.xpath('./ns:AntPhaseCenter/ns:ACFId', namespaces=good_xml['nsmap'])[-1].text += '_wrong'
    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_antenna')
    assert len(cphd_con.failures())
예제 #4
0
def test_check_classification_and_release_info_error(good_xml, good_header):
    bad_xml = copy_xml(good_xml['without_ns'])

    bad_xml.find('./CollectionID/ReleaseInfo').text += '-make-bad'
    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=good_header, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_classification_and_release_info')
    assert len(cphd_con.failures()) > 0
예제 #5
0
def test_extended_imagearea(xml_with_extendedarea):
    root, nsmap = xml_with_extendedarea

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    cphd_con.check(['check_extended_imagearea_polygon', 'check_extended_imagearea_x1y1_x2y2'])
    assert len(cphd_con.failures()) == 0
예제 #6
0
def test_check_unconnected_ids_severed_node(good_xml):
    bad_xml = copy_xml(good_xml['without_ns'])

    bad_xml.find('./Dwell/CODTime/Identifier').text += '-make-bad'
    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=good_header, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_unconnected_ids')
    assert len(cphd_con.failures()) > 0
예제 #7
0
def test_xml_schema_error(good_xml):
    bad_xml = copy_xml(good_xml['with_ns'])

    remove_nodes(*bad_xml.xpath('./ns:Global/ns:DomainType', namespaces=good_xml['nsmap']))
    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_against_schema')
    assert len(cphd_con.failures()) > 0
예제 #8
0
def test_polygon_size_error(good_xml):
    bad_xml = copy_xml(good_xml['with_ns'])
    ia_polygon_node = bad_xml.find('./ns:SceneCoordinates/ns:ImageArea/ns:Polygon', namespaces=good_xml['nsmap'])
    ia_polygon_node.attrib['size'] = "12345678890"

    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_global_imagearea_polygon')
    assert len(cphd_con.failures()) > 0
예제 #9
0
def test_txrcv(xml_with_txrcv):
    chan_ids, root, nsmap = xml_with_txrcv

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = ['check_channel_txrcv_exist_{}'.format(key) for key in chan_ids]
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == 0
예제 #10
0
def test_antenna_missing_channel_node(good_xml_with_antenna):
    bad_xml = copy_xml(good_xml_with_antenna)
    remove_nodes(*bad_xml.findall('./Channel/Parameters/Antenna'))

    cphd_con = CphdConsistency(
        bad_xml, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    cphd_con.check('check_antenna_ids_in_channel')
    assert len(cphd_con.failures()) > 0
예제 #11
0
def test_extended_imagearea_polygon_bad_extent(xml_with_extendedarea):
    root, nsmap = xml_with_extendedarea
    root.find('./ns:SceneCoordinates/ns:ExtendedArea/ns:X2Y2/ns:X', namespaces=nsmap).text = '2000'

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    cphd_con.check('check_extended_imagearea_polygon')
    assert len(cphd_con.failures()) > 0
예제 #12
0
def test_fxbwnoise(xml_with_fxbwnoise):
    pvps, root, nsmap = xml_with_fxbwnoise

    cphd_con = CphdConsistency(
        root, pvps=pvps, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = ['check_channel_fxbwnoise_{}'.format(key) for key in pvps.keys()]
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == 0
예제 #13
0
def test_channel_srpfixed(xml_without_srpfixed):
    pvps, root, nsmap = xml_without_srpfixed

    cphd_con = CphdConsistency(
        root, pvps=pvps, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = ['check_channel_srpfixed_{}'.format(key) for key in pvps.keys()]
    tocheck.append('check_file_srpfixed')
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == 0
예제 #14
0
def test_fxbwnoise_bad_domain(xml_with_fxbwnoise):
    pvps, root, nsmap = xml_with_fxbwnoise

    root.find('./ns:Global/ns:DomainType', namespaces=nsmap).text = 'TOA'

    cphd_con = CphdConsistency(
        root, pvps=pvps, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = ['check_channel_fxbwnoise_{}'.format(key) for key in pvps.keys()]
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) > 0
예제 #15
0
def test_error_in_check(good_xml):
    bad_xml = copy_xml(good_xml['with_ns'])
    remove_nodes(*bad_xml.xpath('./ns:Channel/ns:Parameters/ns:DwellTimes/ns:CODId', namespaces=good_xml['nsmap']))

    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    tocheck = []
    for chan_id in bad_xml.findall('./ns:Data/ns:Channel/ns:Identifier', namespaces=good_xml['nsmap']):
        tocheck.append('check_channel_dwell_exist_{}'.format(chan_id.text))
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) > 0
예제 #16
0
def test_signalnormal_bad_pvp(xml_with_signal_normal):
    pvps, root, nsmap = xml_with_signal_normal

    for idx, pvp in enumerate(pvps.values()):
        pvp['SIGNAL'][idx] = 0
    cphd_con = CphdConsistency(root,
                               pvps=pvps,
                               header=None,
                               filename=None,
                               schema=DEFAULT_SCHEMA,
                               check_signal_data=False)
    tocheck = [
        'check_channel_signalnormal_{}'.format(key) for key in pvps.keys()
    ]
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == len(pvps)

    for norm_node in root.findall('./ns:Channel/ns:Parameters/ns:SignalNormal',
                                  namespaces=nsmap):
        norm_node.text = 'false'
    cphd_con = CphdConsistency(root,
                               pvps=pvps,
                               header=None,
                               filename=None,
                               schema=DEFAULT_SCHEMA,
                               check_signal_data=False)
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == 0

    no_sig_pvp = {
        name: np.zeros(pvp.shape, dtype=[('notsignal', 'i8')])
        for name, pvp in pvps.items()
    }
    cphd_con = CphdConsistency(root,
                               pvps=no_sig_pvp,
                               header=None,
                               filename=None,
                               schema=DEFAULT_SCHEMA,
                               check_signal_data=False)
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) > 0
예제 #17
0
def test_check_unconnected_ids_extra_node(good_xml):
    bad_xml = copy_xml(good_xml['without_ns'])

    first_acf = bad_xml.find('./Antenna/AntCoordFrame')
    extra_acf = copy.deepcopy(first_acf)
    extra_acf.find('./Identifier').text += '_superfluous'
    first_acf.getparent().append(extra_acf)

    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=good_header, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_unconnected_ids')
    assert len(cphd_con.failures()) > 0
예제 #18
0
def test_channel_image_area(xml_with_channel_imagearea):
    root, nsmap = xml_with_channel_imagearea

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = []
    for chan_id in root.findall('./ns:Data/ns:Channel/ns:Identifier', namespaces=nsmap):
        tocheck.append('check_channel_imagearea_x1y1_{}'.format(chan_id.text))
        tocheck.append('check_channel_imagearea_polygon_{}'.format(chan_id.text))
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) == 0
예제 #19
0
def test_txrcv_missing_channel_node(xml_with_txrcv):
    chan_ids, root, nsmap = xml_with_txrcv

    chan_param_node = root.xpath('./ns:Channel/ns:Parameters/ns:Identifier[text()="{}"]/..'.format(chan_ids[0]),
                                 namespaces=nsmap)[0]
    remove_nodes(*chan_param_node.findall('./ns:TxRcv', nsmap))

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    cphd_con.check('check_txrcv_ids_in_channel')
    assert len(cphd_con.failures()) > 0
예제 #20
0
def test_polygon_winding_error(good_xml):
    bad_xml = copy_xml(good_xml['with_ns'])
    ia_polygon_node = bad_xml.find('./ns:SceneCoordinates/ns:ImageArea/ns:Polygon', namespaces=good_xml['nsmap'])
    size = int(ia_polygon_node.attrib['size'])
    # Reverse the order of the vertices
    for vertex in ia_polygon_node:
        vertex.attrib['index'] = str(size - int(vertex.attrib['index']) + 1)

    cphd_con = CphdConsistency(
        bad_xml, pvps={}, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)
    cphd_con.check('check_global_imagearea_polygon')
    assert len(cphd_con.failures()) > 0
예제 #21
0
def test_txrcv_bad_rcvid(xml_with_txrcv):
    chan_ids, root, nsmap = xml_with_txrcv

    chan_param_node = root.xpath('./ns:Channel/ns:Parameters/ns:Identifier[text()="{}"]/..'.format(chan_ids[0]),
                                 namespaces=nsmap)[0]
    chan_param_node.xpath('./ns:TxRcv/ns:RcvId', namespaces=nsmap)[-1].text = 'missing'

    cphd_con = CphdConsistency(
        root, pvps=None, header=None, filename=None, schema=DEFAULT_SCHEMA, check_signal_data=False)

    tocheck = ['check_channel_txrcv_exist_{}'.format(key) for key in chan_ids]
    cphd_con.check(tocheck)
    assert len(cphd_con.failures()) > 0