def test_download_options(self): expected = """ <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://earthexplorer.usgs.gov/inventory/soap"> <soapenv:Header/> <soapenv:Body> <soap:downloadOptions soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <datasetName xsi:type="xsd:string">LANDSAT_8</datasetName> <node xsi:type="xsd:string">EE</node> <apiKey xsi:type="xsd:string">USERS API KEY</apiKey> <entityIds xsi:type="soap:ArrayOfString"> <item xsi:type="xsd:string">LC80130292014100LGN00</item> <item xsi:type="xsd:string">LC80130282014100LGN00</item> </entityIds> </soap:downloadOptions> </soapenv:Body> </soapenv:Envelope> """ request = soap.download_options( "LANDSAT_8", "EE", ["LC80130292014100LGN00", "LC80130282014100LGN00"], api_key="USERS API KEY") request = minidom.parseString(request).toprettyxml() assert compare_xml(request, expected)
def download_options(dataset, node, entityids): api_key = _get_api_key() xml = soap.download_options(dataset, node, entityids, api_key=api_key) r = requests.post(USGS_API, xml) root = ElementTree.fromstring(r.text) _check_for_usgs_error(root) items = root.findall("SOAP-ENV:Body/ns1:downloadOptionsResponse/return/item/downloadOptions/item", NAMESPACES) data = map(lambda item: {el.tag: xsi.get(el) for el in item}, items) return data
def download_options(dataset, node, entityids): api_key = _get_api_key() xml = soap.download_options(dataset, node, entityids, api_key=api_key) r = requests.post(USGS_API, xml) root = ElementTree.fromstring(r.text) _check_for_usgs_error(root) items = root.findall( "SOAP-ENV:Body/ns1:downloadOptionsResponse/return/item/downloadOptions/item", NAMESPACES) data = map(lambda item: {el.tag: xsi.get(el) for el in item}, items) return data
def test_download_options(self): expected = """ <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://earthexplorer.usgs.gov/inventory/soap"> <soapenv:Header/> <soapenv:Body> <soap:downloadOptions soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <datasetName xsi:type="xsd:string">LANDSAT_8</datasetName> <node xsi:type="xsd:string">EE</node> <apiKey xsi:type="xsd:string">USERS API KEY</apiKey> <entityIds xsi:type="soap:ArrayOfString"> <item xsi:type="xsd:string">LC80130292014100LGN00</item> <item xsi:type="xsd:string">LC80130282014100LGN00</item> </entityIds> </soap:downloadOptions> </soapenv:Body> </soapenv:Envelope> """ request = soap.download_options("LANDSAT_8", "EE", ["LC80130292014100LGN00", "LC80130282014100LGN00"], api_key="USERS API KEY") request = minidom.parseString(request).toprettyxml() assert compare_xml(request, expected)