def test_get_webservice_cache(self): """ Test caching for WSDL files """ with HTTMock(lambda url, request: self.test_wsdl): service = iprova_plugin._get_webservice() # Repeating same request should not actually fire with HTTMock(lambda url, request: self.fail('Expected one request.')): iprova_plugin._get_webservice() with HTTMock( lambda url, request: self.test_response.format(token='test_token_2') ): answer = service.GetTokenForUser( strTrustedApplicationID=iprova_settings['application_id'], strLoginCode='test_user' ) self.assertEquals(answer, 'test_token_2') with HTTMock( lambda url, request: self.test_response.format(token='test_token_3') ): answer = service.GetTokenForUser( strTrustedApplicationID=iprova_settings['application_id'], strLoginCode='test_user' ) self.assertEquals(answer, 'test_token_3')
def test_get_webservice(self): """ Use test WSDL to check whether or not SUDS is broken. """ def wsdl_mock(url, request): self.assertEquals( url.geturl(), 'http://intranet.organisation.com/' 'Management/Webservices/UserManagementAPI.asmx?WSDL' ) return self.test_wsdl with HTTMock(wsdl_mock): service = iprova_plugin._get_webservice() # Assert the used method is available in WSDL self.assertTrue(hasattr(service, 'GetTokenForUser')) with HTTMock( lambda url, request: self.test_response.format(token='test_token') ): answer = service.GetTokenForUser( strTrustedApplicationID=iprova_settings['application_id'], strLoginCode='test_user' ) self.assertEquals(answer, 'test_token')