def on_start(self): """ This locust framework defined way of preparing test context before task is executed, basic contract is that logic inside of on_start(self) method guaranteed to be executed before methods with @task annotation called :return: None """ self.user = Api.create_fake_user('example-user-%s' % uuid.uuid4()) if self.user: self.room = Api.create_room('Test room', self.user.access_token)
def __init__(self, config): self.Config = config self.Api = Api(self) self.Sockets = Sockets(self) self.FrameHandler = FrameHandler(self) self.Drawer = Drawer(self) self.Event = Event(self) self.Cams = {} self.Modules = {} self.Caps = {} self.init_cams() self.init_modules() self.init_caps()
def create_memberships(self): headers = Headers.get_auth_json_header( self.user['token']['access_token']) data = { 'roomId': '%s' % self.room['id'], 'personEmail': Api.generate_email_address() } self.client.post('/messages', data=json.dumps(data), headers=headers)
class App: """docstring for App""" def __init__(self, config): self.Config = config self.Api = Api(self) self.Sockets = Sockets(self) self.FrameHandler = FrameHandler(self) self.Drawer = Drawer(self) self.Event = Event(self) self.Cams = {} self.Modules = {} self.Caps = {} self.init_cams() self.init_modules() self.init_caps() def init_cams(self): cams = self.Api.findAll('cams') if cams: for cam in cams: self.Cams[cam['_id']] = Cam(cam['_id']) self.Cams[cam['_id']].load(cam) else: print('[App]: No cams, retry.. (theard blocked)') time.sleep(self.Config.no_cams_retry_sleep) self.init_cams() print('[App]: Cams loaded') def init_modules(self): for module in next( os.walk("/".join( [os.path.abspath(os.path.dirname(sys.argv[0])), 'modules'])))[1]: module_class = getattr( __import__(".".join(['modules', module, module]), fromlist=[module]), module) self.Modules[module] = module_class(self) print('[App]: Modules loaded') def init_caps(self): for cam_id in self.Cams: self.Caps[cam_id] = Cap(self, self.Cams[cam_id]) print('[App]: Caps loaded')
def on_start(self): self.user = Api.create_fake_user( display_name='Test User for Send Message') self.room = Api.create_room(title='Hello World', access_token=self.user.access_token)
def __init__(self): Api.__init__(self, "PlacesAPI")
def __init__(self): Api.__init__(self) self.redis = self.get_redis()
def __init__(self): Api.__init__(self, "CashRegistersAPI")