示例#1
0
 def getInterface(self):
     if not self._interface:
         self._interface = getRemoteInterface(self)
         if self._interface:
             self._interfaceName = self._interface.__remote_name__
         else:
             self._interfaceName = None
     return self._interface
示例#2
0
 def getInterface(self):
     if not self._interface:
         self._interface = getRemoteInterface(self)
         if self._interface:
             self._interfaceName = self._interface.__remote_name__
         else:
             self._interfaceName = None
     return self._interface
示例#3
0
    def testInterface1(self):
        # verify that we extract the right interfaces from a local object.
        # also check that the registry stuff works.
        self.setupBrokers()
        rr, target = self.setupTarget(Target())
        iface = getRemoteInterface(target)
        self.assertEqual(iface, RIMyTarget)
        iname = getRemoteInterfaceName(target)
        self.assertEqual(iname, "RIMyTarget")
        self.assertIs(RemoteInterfaceRegistry["RIMyTarget"], RIMyTarget)

        rr, target = self.setupTarget(Target2())
        iname = getRemoteInterfaceName(target)
        self.assertEqual(iname, "RIMyTargetInterface2")
        self.assertIs(RemoteInterfaceRegistry["RIMyTargetInterface2"],
                      RIMyTarget2)
示例#4
0
    def testInterface1(self):
        # verify that we extract the right interfaces from a local object.
        # also check that the registry stuff works.
        self.setupBrokers()
        rr, target = self.setupTarget(Target())
        iface = getRemoteInterface(target)
        self.failUnlessEqual(iface, RIMyTarget)
        iname = getRemoteInterfaceName(target)
        self.failUnlessEqual(iname, "RIMyTarget")
        self.failUnlessIdentical(RemoteInterfaceRegistry["RIMyTarget"],
                                 RIMyTarget)

        rr, target = self.setupTarget(Target2())
        iname = getRemoteInterfaceName(target)
        self.failUnlessEqual(iname, "RIMyTargetInterface2")
        self.failUnlessIdentical(\
            RemoteInterfaceRegistry["RIMyTargetInterface2"], RIMyTarget2)
示例#5
0
    def testInterface2(self):
        # verify that RemoteInterfaces have the right attributes
        t = Target()
        iface = getRemoteInterface(t)
        self.failUnlessEqual(iface, RIMyTarget)

        # 'add' is defined with 'def'
        s1 = RIMyTarget['add']
        self.failUnless(isinstance(s1, RemoteMethodSchema))
        ok, s2 = s1.getKeywordArgConstraint("a")
        self.failUnless(ok)
        self.failUnless(isinstance(s2, schema.IntegerConstraint))
        self.failUnless(s2.checkObject(12, False) == None)
        self.failUnlessRaises(schema.Violation, s2.checkObject, "string",
                              False)
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))

        # 'add1' is defined as a class attribute
        s1 = RIMyTarget['add1']
        self.failUnless(isinstance(s1, RemoteMethodSchema))
        ok, s2 = s1.getKeywordArgConstraint("a")
        self.failUnless(ok)
        self.failUnless(isinstance(s2, schema.IntegerConstraint))
        self.failUnless(s2.checkObject(12, False) == None)
        self.failUnlessRaises(schema.Violation, s2.checkObject, "string",
                              False)
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))

        s1 = RIMyTarget['join']
        self.failUnless(
            isinstance(
                s1.getKeywordArgConstraint("a")[1], schema.StringConstraint))
        self.failUnless(
            isinstance(
                s1.getKeywordArgConstraint("c")[1], schema.IntegerConstraint))
        s3 = RIMyTarget['join'].getResponseConstraint()
        self.failUnless(isinstance(s3, schema.StringConstraint))

        s1 = RIMyTarget['disputed']
        self.failUnless(
            isinstance(
                s1.getKeywordArgConstraint("a")[1], schema.IntegerConstraint))
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))
示例#6
0
    def testInterface2(self):
        # verify that RemoteInterfaces have the right attributes
        t = Target()
        iface = getRemoteInterface(t)
        self.failUnlessEqual(iface, RIMyTarget)

        # 'add' is defined with 'def'
        s1 = RIMyTarget['add']
        self.failUnless(isinstance(s1, RemoteMethodSchema))
        ok, s2 = s1.getKeywordArgConstraint("a")
        self.failUnless(ok)
        self.failUnless(isinstance(s2, schema.IntegerConstraint))
        self.failUnless(s2.checkObject(12, False) == None)
        self.failUnlessRaises(schema.Violation,
                              s2.checkObject, "string", False)
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))

        # 'add1' is defined as a class attribute
        s1 = RIMyTarget['add1']
        self.failUnless(isinstance(s1, RemoteMethodSchema))
        ok, s2 = s1.getKeywordArgConstraint("a")
        self.failUnless(ok)
        self.failUnless(isinstance(s2, schema.IntegerConstraint))
        self.failUnless(s2.checkObject(12, False) == None)
        self.failUnlessRaises(schema.Violation,
                              s2.checkObject, "string", False)
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))

        s1 = RIMyTarget['join']
        self.failUnless(isinstance(s1.getKeywordArgConstraint("a")[1],
                                   schema.StringConstraint))
        self.failUnless(isinstance(s1.getKeywordArgConstraint("c")[1],
                                   schema.IntegerConstraint))
        s3 = RIMyTarget['join'].getResponseConstraint()
        self.failUnless(isinstance(s3, schema.StringConstraint))

        s1 = RIMyTarget['disputed']
        self.failUnless(isinstance(s1.getKeywordArgConstraint("a")[1],
                                   schema.IntegerConstraint))
        s3 = s1.getResponseConstraint()
        self.failUnless(isinstance(s3, schema.IntegerConstraint))
示例#7
0
 def testInterface3(self):
     t = TargetWithoutInterfaces()
     iface = getRemoteInterface(t)
     self.failIf(iface)
示例#8
0
def getRemoteInterfaceName(obj):
    i = getRemoteInterface(obj)
    return i.__remote_name__
示例#9
0
 def testInterface3(self):
     t = TargetWithoutInterfaces()
     iface = getRemoteInterface(t)
     self.assertFalse(iface)
示例#10
0
def getRemoteInterfaceName(obj):
    i = getRemoteInterface(obj)
    return i.__remote_name__
示例#11
0
 def testInterface3(self):
     t = TargetWithoutInterfaces()
     iface = getRemoteInterface(t)
     self.failIf(iface)