def test_str_magic_behaves(self): oid_details = make_login_details( email='email address', identity_url='identity url') a_user, same_user = readit.User(), readit.User() a_user.login(oid_details) same_user.login(oid_details) a_user.user_id = 'user id' same_user.user_id = a_user.user_id self.assertEquals(str(a_user), str(same_user)) different_user = readit.User() different_user.user_id = a_user.user_id different_user.login(make_login_details( email=oid_details.email, identity_url='other url')) self.assertNotEquals(str(a_user), str(different_user)) different_user.login(make_login_details( email='other email', identity_url=oid_details.identity_url)) self.assertNotEquals(str(a_user), str(different_user)) different_user.login(oid_details) different_user.user_id = 'other user id' self.assertNotEquals(str(a_user), str(different_user))
def setUp(self): super(LoginTests, self).setUp() self.saved_oid = readit.app.oid self.fake_user = readit.User() self.fake_user.email = '<EmailAddress>' self.fake_user.user_id = '<UserId>' self.fake_oid_details = mock.Mock() self.fake_oid_details.openid = '<ReturnedOpenId>' self.fake_oid_details.identity_url = '<IdentityUrl>' self.fake_oid_details.email = '<EmailAddress>'
def initialize_user(): """Make sure that ``flask.g.user`` is initialized to an instance of :py:class:`readit.User`.""" flask.g.user = readit.User(flask.session.get('session_key', None)) flask.g.user.user_id = flask.session.get('user_id', None)
def test_session_key_is_preserved(self): u = readit.User(self.random_session_key) self.assertEqual(u.session_key, self.random_session_key)
def setUp(self): self.random_session_key = os.urandom(16) self.user = readit.User(None)
def create_storable_instance(self): a_user = readit.User() a_user.email = '<EMailAddress>' return a_user