예제 #1
0
파일: app_test.py 프로젝트: cpadavis/swap
    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
예제 #2
0
    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()
예제 #3
0
    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()
예제 #4
0
파일: app_test.py 프로젝트: cpadavis/swap
    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]
예제 #5
0
파일: app_test.py 프로젝트: cpadavis/swap
    def test_recent_cl_false(self):
        api = app.API(None)

        assert api._is_recent_cl({'id': 1}) is False
        assert api._recent_cl == [1]