def testTakesRemoteInterfaceBad2(self): rr, target = self.setupTarget(TypesTarget(), True) # takes_remoteinterface is specified to accept an RIDummy d = rr.callRemote('takes_remoteinterface', TypesTarget()) def _check_failure(f): f.trap(Violation) self.assertIn("RITypes.takes_remoteinterface(a=))", str(f)) self.assertIn(" does not provide RemoteInterface ", str(f)) self.assertIn("foolscap.test.common.RIDummy", str(f)) self.deferredShouldFail(d, checker=_check_failure) return d
def testReturnsInterfaceBad(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('returns_interface', False) def _check_failure(f): f.trap(Violation) print(f) self.deferredShouldFail(d, checker=_check_failure) return d
def testReturnsInterfaceGood(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('returns_interface', True) def _check(res): #self.failUnless(isinstance(res, RemoteReference)) self.assertTrue(IFoo.providedBy(res)) d.addCallback(_check) return d
def testReturnsRemoteInterfaceGood(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('returns_remoteinterface', 1) def _check(res): self.assertTrue(isinstance(res, RemoteReference)) #self.failUnless(RIDummy.providedBy(res)) self.failUnlessRemoteProvides(res, RIDummy) d.addCallback(_check) return d
def testTakesRemoteInterfaceBad(self): rr, target = self.setupTarget(TypesTarget(), True) # takes_remoteinterface is specified to accept an RIDummy d = rr.callRemote('takes_remoteinterface', 12) def _check_failure(f): f.trap(Violation) self.assertIn("RITypes.takes_remoteinterface(a=))", str(f)) self.assertIn("'12' is not a Referenceable", str(f)) self.deferredShouldFail(d, checker=_check_failure) return d
def testNoneBad(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('returns_none', False) def _check_failure(f): f.trap(Violation) self.assertIn( "(in return value of <foolscap.test.common.TypesTarget object", str(f)) self.assertIn(">.returns_none", str(f)) self.assertIn("'not None' is not None", str(f)) self.deferredShouldFail(d, checker=_check_failure) return d
def testReturnsRemoteInterfaceBad(self): rr, target = self.setupTarget(TypesTarget(), True) # returns_remoteinterface is specified to return an RIDummy d = rr.callRemote('returns_remoteinterface', 0) def _check_failure(f): f.trap(Violation) self.assertIn( "(in return value of <foolscap.test.common.TypesTarget object at ", str(f)) self.assertIn(">.returns_remoteinterface)", str(f)) self.assertIn("'15' is not a Referenceable", str(f)) self.deferredShouldFail(d, checker=_check_failure) return d
def testReturnsRemoteInterfaceBad2(self): rr, target = self.setupTarget(TypesTarget(), True) # returns_remoteinterface is specified to return an RIDummy d = rr.callRemote('returns_remoteinterface', -1) def _check_failure(f): f.trap(Violation) self.failUnlessIn( "(in return value of <foolscap.test.common.TypesTarget object at ", str(f)) self.failUnlessIn(">.returns_remoteinterface)", str(f)) self.failUnlessIn("<foolscap.test.common.TypesTarget object ", str(f)) self.failUnlessIn(" does not provide RemoteInterface ", str(f)) self.failUnlessIn("foolscap.test.common.RIDummy", str(f)) self.deferredShouldFail(d, checker=_check_failure) return d
def testTakesInterfaceGood(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('takes_interface', DummyTarget()) d.addCallback(lambda res: self.assertEqual(res, "good")) return d
def testNoneGood(self): rr, target = self.setupTarget(TypesTarget(), True) d = rr.callRemote('returns_none', True) d.addCallback(lambda res: self.assertEqual(res, None)) return d