def test_error_server_busy(self): # Test that we can parse an ErrorServerBusy response version = mock_version(build=EXCHANGE_2010) ws = GetRoomLists(mock_protocol(version=version, service_endpoint='example.com')) xml = b'''\ <?xml version='1.0' encoding='utf-8'?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <s:Fault> <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorServerBusy</faultcode> <faultstring xml:lang="en-US">The server cannot service this request right now. Try again later.</faultstring> <detail> <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"> ErrorServerBusy </e:ResponseCode> <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"> The server cannot service this request right now. Try again later. </e:Message> <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <t:Value Name="BackOffMilliseconds">297749</t:Value> </t:MessageXml> </detail> </s:Fault> </s:Body> </s:Envelope>''' header, body = ws._get_soap_parts(response=MockResponse(xml)) with self.assertRaises(ErrorServerBusy) as cm: ws._get_elements_in_response(response=ws._get_soap_messages(body=body)) self.assertEqual(cm.exception.back_off, 297.749)
def test_get_roomlists_parsing(self): # Test static XML since server has no roomlists ws = GetRoomLists(self.account.protocol) xml = b'''\ <?xml version="1.0" ?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <m:GetRoomListsResponse ResponseClass="Success" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <m:ResponseCode>NoError</m:ResponseCode> <m:RoomLists> <t:Address> <t:Name>Roomlist</t:Name> <t:EmailAddress>[email protected]</t:EmailAddress> <t:RoutingType>SMTP</t:RoutingType> <t:MailboxType>PublicDL</t:MailboxType> </t:Address> <t:Address> <t:Name>Roomlist</t:Name> <t:EmailAddress>[email protected]</t:EmailAddress> <t:RoutingType>SMTP</t:RoutingType> <t:MailboxType>PublicDL</t:MailboxType> </t:Address> </m:RoomLists> </m:GetRoomListsResponse> </s:Body> </s:Envelope>''' _, body = ws._get_soap_parts(response=MockResponse(xml)) res = ws._get_elements_in_response(response=ws._get_soap_messages(body=body)) self.assertSetEqual( {RoomList.from_xml(elem=elem, account=None).email_address for elem in res}, {'*****@*****.**', '*****@*****.**'} )