def after_request(response): """Remove/Add a couple of things after the request.""" session_db.remove() add_sec_headers(response) add_csp(response) ab_init(response) return response
def after_request(response): """Remove/Add a couple of things after the request.""" session_db.remove() add_sec_headers(response) add_csp(response) if app.config['AB_EXPERIMENTS']: ab_init(response) return response
def test_ab_init_active(self): """Check if ab_init doesn't set cookies if experiment already active""" cookie = 'exp-1=ui-change-v1; Path=/' with webcompat.app.test_request_context( '/', method='GET', environ_base={'HTTP_COOKIE': cookie}): webcompat.app.config['AB_EXPERIMENTS'] = { 'exp-1': { 'variations': { 'ui-change-v1': (0, 20), 'ui-change-v2': (20, 100) }, 'max-age': 604800 } } response = self.app.get('/') response.set_cookie = Mock() ab_init(response) response.set_cookie.assert_not_called()