Ejemplo n.º 1
0
Archivo: mock.py Proyecto: splice/gofer
def test():
    a = proxy.agent('123')
    dogA = a.Dog()
    dogA.bark('hello')
    dogA.wag(2)
    print 'calls for dogA.bark()'
    for call in dogA.bark.history():
        print call
    print 'calls for dogA.wag()'
    for call in dogA.wag.history():
        print call
    b = proxy.agent('123b')
    dogB = b.Dog()
    dogB.bark('foo')
    dogB.bark('bar')
    print 'calls for dogB.bark()'
    for call in dogB.bark.history():
        print call
    print 'reset B'
    mock.reset()
    b = proxy.agent('123b')
    dogB = b.Dog()
    print 'calls for dogB'
    for call in dogB.bark.history():
        print call
Ejemplo n.º 2
0
 def test_agent(self, _agent):
     url = 'qpid+amqp://host'
     address = 'xyz'
     options = {'A': 1, 'B': 2}
     proxy = agent(url, address, **options)
     _agent.assert_called_with(url, address, **options)
     self.assertEqual(proxy, _agent.return_value)
Ejemplo n.º 3
0
 def test_agent(self, _agent):
     url = 'qpid+amqp://host'
     address = 'xyz'
     options = {'A': 1, 'B': 2}
     proxy = agent(url, address, **options)
     _agent.assert_called_with(url, address, **options)
     self.assertEqual(proxy, _agent.return_value)
Ejemplo n.º 4
0
 def __init__(self, uuid, **options):
     """
     @param __agent: The wrapped gofer agent object.
     @type __agent: Agent
     """
     options['url'] = \
         config.get('messaging', 'url')
     self.__agent = proxy.agent(uuid, **options)
Ejemplo n.º 5
0
 def call(self, classname, method, request, replyto, any):
     options = Options(self.options)
     if replyto:
         options.ctag = ReplyManager.CTAG
         options.watchdog = Services.watchdog
         options.any = dict(any=any, replyto=replyto)
     agent = proxy.agent(self.uuid, **options)
     Class = agent[classname]
     inst = Class()
     cntr = request.cntr
     if cntr:
         inst(*cntr[0], **cntr[1])
     fn = inst[method]
     return fn(*request.args, **request.kwargs)
Ejemplo n.º 6
0
 def call(self, classname, method, request, replyto, any):
     options = Options(self.options)
     if replyto:
         options.ctag = ReplyManager.CTAG
         options.watchdog = Services.watchdog
         options.any = dict(any=any, replyto=replyto)
     agent = proxy.agent(self.uuid, **options)
     Class = agent[classname]
     inst = Class()
     cntr = request.cntr
     if cntr:
         inst(*cntr[0], **cntr[1])
     fn = inst[method]
     return fn(*request.args, **request.kwargs)        
Ejemplo n.º 7
0
Archivo: mock.py Proyecto: splice/gofer
        print call
    print 'calls for dogA.wag()'
    for call in dogA.wag.history():
        print call
    b = proxy.agent('123b')
    dogB = b.Dog()
    dogB.bark('foo')
    dogB.bark('bar')
    print 'calls for dogB.bark()'
    for call in dogB.bark.history():
        print call
    print 'reset B'
    mock.reset()
    b = proxy.agent('123b')
    dogB = b.Dog()
    print 'calls for dogB'
    for call in dogB.bark.history():
        print call

if __name__ == '__main__':
    test()
    uuid = 'xyz'
    main(uuid)
    agent = proxy.agent(uuid)
    d = agent.Dog()
    for x in d.bark.history():
        print x
    print 'finished.'