From 9f3e0709f5d53f7fdc5f49673ac39066b1abbbfd Mon Sep 17 00:00:00 2001 From: peppelinux Date: Tue, 1 Jun 2021 22:41:40 +0200 Subject: [PATCH] fix: Extentions inside ContactPerson --- src/spid_sp_test/metadata_public.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/spid_sp_test/metadata_public.py b/src/spid_sp_test/metadata_public.py index 422bca1..ca3ce78 100644 --- a/src/spid_sp_test/metadata_public.py +++ b/src/spid_sp_test/metadata_public.py @@ -40,12 +40,19 @@ def test_Contacts_PubPriv(self, contact_type="other"): return self.is_ok(f'{self.__class__.__name__}.test_Contacts_PubPriv') def test_Extensions_PubPriv(self): - exts = self.doc.xpath('//ContactPerson/Extensions') - self._assertTrue( - len(exts) == 1, - 'Only one Extensions element inside ContactPerson element MUST be present', - description = exts - ) + _conts = self.doc.xpath('//ContactPerson') + + for cont in _conts: + ext_cnt = 0 + for child in cont.getchildren(): + if child.tag == 'Extension': + ext_cnt += 1 + + self._assertFalse( + ext_cnt > 1, + 'Only one Extensions element inside ContactPerson element MUST be present', + description = etree.tostring(cont).decode() + ) orgs = self.doc.xpath('//EntityDescriptor/Organization/OrganizationName') if len(orgs) >= 1: