def test_S2220_xml(self): evt2220 = xml.load_fromfile(os.path.join(here, 'xml', 'S-2220.xml')) isvalid = True try: xml.XMLValidate(evt2220).validate() except AssertionError: isvalid = False self.assertTrue(isvalid)
def test_xml_send_batch(self): evt2220 = xml.load_fromfile( os.path.join(here, 'xml', 'S-2220_not_signed.xml')) employer_id = {'tpInsc': 2, 'nrInsc': '12345678901234'} ws = client.WSClient(pfx_file=os.path.join(there, 'certs', 'libesocial-cert-test.pfx'), pfx_passw='cert@test', employer_id=employer_id, sender_id=employer_id) ws.add_event(evt2220) batch_to_send = ws._make_send_envelop(1, employer_id, employer_id) ws.validate_envelop('send', batch_to_send)
def test_xml_sign(self): evt2220_not_signed = xml.load_fromfile( os.path.join(here, 'xml', 'S-2220_not_signed.xml')) xmlschema = xml.XMLValidate(evt2220_not_signed) isvalid = xmlschema.isvalid() self.assertFalse(isvalid, msg=str(xmlschema.last_error)) # Test signing cert_data = pkcs12_data(cert_file=os.path.join( there, 'certs', 'libesocial-cert-test.pfx'), password='******') evt2220_signed = xml.sign(evt2220_not_signed, cert_data) xml.XMLValidate(evt2220_signed).validate()