def test_not_logged_in(pyramid_request): class A(object): pass def _nop(a): return 3 f = not_logged_in(None)(_nop) a = A() a.request = pyramid_request assert f(a) == 3
def test_not_logged_in_login(dummy_login, pyramid_request): class A(object): pass def _nop(a): pass dummy_login(4) f = not_logged_in()(_nop) a = A() a.request = pyramid_request ret = f(a) assert ret.code == 302 q = pyramid_request.session.peek_flash() assert len(q) == 1 assert q[0] == ("This action does not make sense if you are already " "logged in!")
def test_not_logged_in_msg(dummy_login, pyramid_request): class A(object): pass def _nop(b): pass dummy_login(5) q = pyramid_request.session.peek_flash() assert len(q) == 0 f = not_logged_in("Testmsg")(_nop) a = A() a.request = pyramid_request ret = f(a) assert ret.code == 302 q = pyramid_request.session.peek_flash() assert len(q) == 1 assert q[0] == ("Testmsg")