def extract_body(xml, method): soap = Soap() namespaces = { 'soapenv': 'http://www.w3.org/2003/05/soap-envelope' } node = xml.findall("./soapenv:Body", namespaces) code = 0 for child in node[0].getchildren(): data = dict() for ele in child.getchildren(): if "arg0" in ele.tag or "in0" in ele.tag: data["msisdn"] = ele.text elif "arg1" in ele.tag or "in1" in ele.tag: data["iccid"] = ele.text elif "arg2" in ele.tag or "in2" in ele.tag: data["cveplan"] = ele.text elif "arg3" in ele.tag or "in3" in ele.tag: data["cvetpoinst"] = ele.text logger.info("New transaction", extra={'props': {"method": child.tag, "app": config["name"], "data": data}}) if method == "POST": if "alta_aprov_telcel" in child.tag: code = soap.alta(data) elif "suspender_aprov_telcel" in child.tag: code = soap.suspension(data) elif "reactivar_aprov_telcel" in child.tag: code = soap.reactivacion(data) elif "cancelar_aprov_telcel" in child.tag: code = soap.cancelacion(data) elif "modificar_aprov_telcel" in child.tag: data["cveplan"] = data["iccid"] code = soap.update_plan(data) elif "com6_aprov_telcel" in child.tag: logger.info("Request COM_6 processing", extra={'props': {"raw": data, "app": config["name"], "label": config["name"]}}) code = soap.com_6(data) return code
def test_cancelado(self): params = dict() params["msisdn"] = "" params["iccid"] = "" soap = Soap() js = soap.cancelacion(params) self.assertTrue(js == 504)
def test_exitosa(self): params = dict() params["msisdn"] = "525546868951" params["iccid"] = "019912311111112223" params["cveplan"] = "" params["cvetpoinst"] = "" soap = Soap() js = soap.cancelacion(params) self.assertTrue(js == 0)