def test_get_kml_doc(self): kml_bytes = """ <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Document> <name>CSR5r3_annual</name> <GroundOverlay id="groundoverlay"> <name>CSR5r3_annual</name> <description><![CDATA[]]></description> <color>ffffffff</color> <visibility>1</visibility> <extrude>0</extrude> <Icon> <href>CSR5r3_annual.png</href> <viewBoundScale>1</viewBoundScale> </Icon> <LatLonBox> <north>70.000000</north> <south>-60.500000</south> <east>180.000000</east> <west>-180.000000</west> <rotation>0.0000000000000000</rotation> </LatLonBox> </GroundOverlay> </Document> </kml> """.strip() kml_doc, ns = utils.get_kml_doc(kml_bytes) self.assertTrue(etree.QName(kml_doc.tag).localname, "kml") self.assertIn("kml", ns.keys())
def test_extract_bbox_param(self): fake_north = "70.000" kml_bytes = f""" <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Document> <GroundOverlay id="groundoverlay"> <LatLonBox> <north>{fake_north}</north> </LatLonBox> </GroundOverlay> </Document> </kml> """.strip() kml_doc, ns = get_kml_doc(kml_bytes) result = upload_preprocessing._extract_bbox_param(kml_doc, ns, "north") self.assertEqual(result, fake_north)
def test_extract_bbox_param(self): fake_north = "70.000" kml_bytes = """ <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Document> <GroundOverlay id="groundoverlay"> <LatLonBox> <north>{}</north> </LatLonBox> </GroundOverlay> </Document> </kml> """.format(fake_north).strip() kml_doc, ns = get_kml_doc(kml_bytes) result = upload_preprocessing._extract_bbox_param( kml_doc, ns, "north") self.assertEqual(result, fake_north)