def test_recent_cl_full(self): api = app.API(None) api._recent_cl = list(range(10)) api._is_recent_cl({'id': 12}) compare = list(range(1, 10)) + [12] assert api._recent_cl == compare
def run(args, swap=None): control = caesar.init_threader(swap) api = caesar.API(control) logger.info('Registering swap in caesar') if args.register: # Try to deregister swap from caesar on exit atexit.register(CaesarConfig.unregister()) # Register swap in caesar CaesarConfig.register() logger.info('launching flask app') api.run()
def run(swap=None): if CaesarConfig.is_registered(): raise RuntimeError( 'Another instance of SWAP is already registered with caesar.') control = caesar.init_threader(swap) api = caesar.API(control) logger.info('Registering swap in caesar') # Try to disable swap in caesar on exit atexit.register(CaesarConfig.disable) # Register swap in caesar CaesarConfig.register() logger.info('launching flask app') api.run()
def test_recent_cl_true(self): api = app.API(None) api._is_recent_cl({'id': 1}) assert api._is_recent_cl({'id': 1}) is True assert api._recent_cl == [1]
def test_recent_cl_false(self): api = app.API(None) assert api._is_recent_cl({'id': 1}) is False assert api._recent_cl == [1]