def test_resolvenames_parsing(self): # Test static XML since server has no roomlists xml = b'''\ <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <m:ResolveNamesResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <m:ResponseMessages> <m:ResolveNamesResponseMessage ResponseClass="Warning"> <m:MessageText>Multiple results were found.</m:MessageText> <m:ResponseCode>ErrorNameResolutionMultipleResults</m:ResponseCode> <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey> <m:ResolutionSet TotalItemsInView="2" IncludesLastItemInRange="true"> <t:Resolution> <t:Mailbox> <t:Name>John Doe</t:Name> <t:EmailAddress>[email protected]</t:EmailAddress> <t:RoutingType>SMTP</t:RoutingType> <t:MailboxType>Mailbox</t:MailboxType> </t:Mailbox> </t:Resolution> <t:Resolution> <t:Mailbox> <t:Name>John Deer</t:Name> <t:EmailAddress>[email protected]</t:EmailAddress> <t:RoutingType>SMTP</t:RoutingType> <t:MailboxType>Mailbox</t:MailboxType> </t:Mailbox> </t:Resolution> </m:ResolutionSet> </m:ResolveNamesResponseMessage> </m:ResponseMessages> </m:ResolveNamesResponse> </s:Body> </s:Envelope>''' ws = ResolveNames(self.account.protocol) ws.return_full_contact_data = False self.assertSetEqual({m.email_address for m in ws.parse(xml)}, {'*****@*****.**', '*****@*****.**'})
def test_element_container(self): ws = ResolveNames(self.account.protocol) xml = b"""\ <?xml version="1.0" encoding="utf-8" ?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <m:ResolveNamesResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"> <m:ResponseMessages> <m:ResolveNamesResponseMessage ResponseClass="Success"> <m:ResponseCode>NoError</m:ResponseCode> </m:ResolveNamesResponseMessage> </m:ResponseMessages> </m:ResolveNamesResponse> </s:Body> </s:Envelope>""" with self.assertRaises(TransportError) as e: # Missing ResolutionSet elements list(ws.parse(xml)) self.assertIn("ResolutionSet elements in ResponseMessage", e.exception.args[0])