def test_method(self):
            msg1 = 'Hello '
            msg2 = 'world'
            exc_msg = "Haw haw! -with Nelson's voice"
            methods = ('method1', 'method2', 'method3', 'method4')

            class Fake:
                def __init__(self):
                    self._server = self

                def method1(self, arg1):
                    return arg1 + msg2

                def method2(self):
                    raise SOAPpy.faultType(faultcode='exceptions.TypeError',
                                           faultstring=exc_msg,
                                           detail="it doesn't really matter")

                def method3(self):
                    raise SOAPpy.faultType(
                        faultcode='this.class.does.not.exist',
                        faultstring="this won't be read",
                        detail="it doesn't really matter")

                def method4(self):
                    raise NameError('ha ha')

            fake = Fake()

            newfunctions = []
            for i in methods:
                newfunction = ClientSOAP._generate_stub(i)
                newfunctions.append(newfunction)

            if ServerSOAP.SERIALIZE:
                #TODO: this must be tested
                return
            self.assertEquals(msg1 + msg2, newfunctions[0](fake, msg1))

            self.assertRaises(TypeError, newfunctions[1], fake)

            the_error = None
            try:
                newfunctions[1](fake)
            except TypeError as te:
                the_error = te

            self.assertEquals(the_error.args[0], exc_msg)

            self.assertRaises(Exceptions.UnknownFaultType, newfunctions[2],
                              fake)

            self.assertRaises(ProtocolErrors.UnknownRemoteError,
                              newfunctions[3], fake)
Example #2
0
 def create_client(self, methods):
     try:
         client_class = ClientSOAP.generate(methods)
     except Exception as e:
         raise ProtocolErrors.ClientClassCreationError(
             ("Client class creation exception: %s" % e), e)
     try:
         return client_class(url=self.ip_address, port=self.port)
     except Exception as e:
         raise ProtocolErrors.ClientInstanciationError(
             ("Unable to instanciate the SOAP client: %s" % e), e)
Example #3
0
 def create_client(self,methods):
     try:
         client_class = ClientSOAP.generate(methods)
     except Exception as e:
         raise ProtocolErrors.ClientClassCreationError(
                 ("Client class creation exception: %s" % e),
                 e
             )
     try:
         return client_class(url = self.ip_address, port = self.port)
     except Exception as e:
         raise ProtocolErrors.ClientInstanciationError(("Unable to instanciate the SOAP client: %s" % e),e)
 def func():
     ClientClass = ClientSOAP.generate(['method1'])
     ClientClass('', 10464)
 def test_generation(self):
     ClientSOAP.generate(['method1'])
 def test_generation(self):
     ClientSOAP.generate(['method1'])
        def test_method(self):
            msg1 = 'Hello '
            msg2 = 'world'
            exc_msg = "Haw haw! -with Nelson's voice"
            methods = ('method1','method2','method3','method4')

            class Fake:
                def __init__(self):
                    self._server = self
                def method1(self, arg1):
                    return arg1 + msg2
                def method2(self):
                    raise SOAPpy.faultType(
                            faultcode='exceptions.TypeError',
                            faultstring=exc_msg,
                            detail = "it doesn't really matter"
                        )
                def method3(self):
                    raise SOAPpy.faultType(
                            faultcode='this.class.does.not.exist',
                            faultstring="this won't be read",
                            detail = "it doesn't really matter"
                        )

                def method4(self):
                    raise NameError('ha ha')

            fake = Fake()

            newfunctions = []
            for i in methods:
                newfunction = ClientSOAP._generate_stub(i)
                newfunctions.append(newfunction)

            if ServerSOAP.SERIALIZE:
                #TODO: this must be tested
                return
            self.assertEquals(msg1 + msg2,newfunctions[0](fake,msg1))

            self.assertRaises(
                    TypeError,
                    newfunctions[1],
                    fake
                )

            the_error = None
            try:
                newfunctions[1](fake)
            except TypeError as te:
                the_error = te

            self.assertEquals( the_error.args[0], exc_msg )

            self.assertRaises(
                    Exceptions.UnknownFaultType,
                    newfunctions[2],
                    fake
                )

            self.assertRaises(
                    ProtocolErrors.UnknownRemoteError,
                    newfunctions[3],
                    fake
                )
 def func():
     ClientClass = ClientSOAP.generate(['method1'])
     ClientClass('', 10464)