def test_forwardCalls(self): cb = ContextBroker() fwdCalls = { 'getToi': 1, 'addToi': 1, 'createToi': 3, 'changeToi': 2, 'deleteToi': 1, 'register': 1, 'runQuery': 1, 'requestAttribute': 2, 'callMethod': 1, 'newId': 0, } callCollector = CallCollector() cb.pushContext(callCollector) expected = [] for call, argN in fwdCalls.items(): args = tuple(object() for i in range(argN)) retVal = getattr(cb, call)(*args) expected.append((call, args, {}, retVal)) assert callCollector.calls == expected
def test_popContext_returnValOk(self): cb = ContextBroker() ctx = object() cb.pushContext(ctx) assert cb.context is ctx assert cb.popContext() is ctx
def test_otherThread_startsEmpty(self): cb = ContextBroker() ctx = object() cb.pushContext(ctx) def getContext(): return cb.context py.test.raises(LookupError, runInThread, 1.0, getContext)
def test_effectOfPopContextOk(self): cb = ContextBroker() py.test.raises(IndexError, cb.popContext) ctx1 = object() ctx2 = object() cb.pushContext(ctx1) cb.pushContext(ctx2) assert cb.context is ctx2 assert cb.popContext() is ctx2 assert cb.context is ctx1
def test_pushContext(self): cb = ContextBroker() ctx = object() cb.pushContext(ctx) assert cb.context is ctx