Back to index

rabbitmq-server  2.8.4
Classes | Functions
parsing Namespace Reference

Classes

class  TestParsing

Functions

def connect

Detailed Description

Few tests for a rabbitmq-stomp adaptor. They intend to increase code coverage
of the erlang stomp code.

Function Documentation

def parsing.connect (   cnames)
Decorator that creates stomp connections and issues CONNECT 

Definition at line 12 of file parsing.py.

00012 
00013 def connect(cnames):
00014     ''' Decorator that creates stomp connections and issues CONNECT '''
00015     cmd=('CONNECT\n'
00016         'login:guest\n'
00017         'passcode:guest\n'
00018         '\n'
00019         '\n\0')
00020     resp = ('CONNECTED\n'
00021             'session:(.*)\n'
00022             'heart-beat:0,0\n'
00023             'server:RabbitMQ/(.*)\n'
00024             'version:1.0\n'
00025             '\n\x00')
00026     def w(m):
00027         @functools.wraps(m)
00028         def wrapper(self, *args, **kwargs):
00029             for cname in cnames:
00030                 sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
00031                 sd.settimeout(30000)
00032                 sd.connect((self.host, self.port))
00033                 sd.sendall(cmd)
00034                 self.match(resp, sd.recv(4096))
00035                 setattr(self, cname, sd)
00036             try:
00037                 r = m(self, *args, **kwargs)
00038             finally:
00039                 for cname in cnames:
00040                     try:
00041                         getattr(self, cname).close()
00042                     except IOError:
00043                         pass
00044             return r
00045         return wrapper
00046     return w
00047 

Here is the caller graph for this function: