Ejemplo n.º 1
0
 def test_get_by_role(self):
     user = create_user()
     create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assertTrue(user in facilitators)
Ejemplo n.º 2
0
 def test_get_by_role(self):
     user = create_user()
     create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assertTrue(user in facilitators)
Ejemplo n.º 3
0
 def test_enabled(self):
     uid = u'jdoe'
     create_user(uid=uid)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(user.enabled)  # this is what we want most of the time
     user.enabled = False
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Ejemplo n.º 4
0
 def test_enabled(self):
     uid = u'jdoe'
     create_user(uid=uid)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(user.enabled)  # this is what we want most of the time
     user.enabled = False
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Ejemplo n.º 5
0
 def test_creation(self):
     uid = u'jdoe'
     firstname = u'John'
     lastname = u'Doe'
     create_user(uid=uid, firstname=firstname, lastname=lastname)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.uid, uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
     self.assert_(user.enabled)
Ejemplo n.º 6
0
 def test_creation(self):
     uid = u'jdoe'
     firstname = u'John'
     lastname = u'Doe'
     create_user(uid=uid, firstname=firstname, lastname=lastname)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.uid, uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
     self.assert_(user.enabled)
Ejemplo n.º 7
0
 def test_by_email(self):
     email = u'*****@*****.**'
     create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         email=email,
     )
     user = self.user_repository.get_by_email(email)
     self.assert_(user is not None)
     self.assertEquals(email, user.email)
     self.assert_(
         self.user_repository.get_by_email(user.email + u'XXX') is None)
Ejemplo n.º 8
0
 def test_by_email(self):
     email = u'*****@*****.**'
     create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         email=email,
     )
     user = self.user_repository.get_by_email(email)
     self.assert_(user is not None)
     self.assertEquals(email, user.email)
     self.assert_(
         self.user_repository.get_by_email(user.email + u'XXX') is None)
Ejemplo n.º 9
0
 def test_photo(self):
     user = create_user()
     photo = self.create_photo(50)
     user.photo = photo
     session.flush()
     self.assertTrue(user.photo is not None)
     user.photo = None
     self.assertTrue(user.photo is None)
Ejemplo n.º 10
0
 def test_photo(self):
     user = create_user()
     photo = self.create_photo(50)
     user.photo = photo
     session.flush()
     self.assertTrue(user.photo is not None)
     user.photo = None
     self.assertTrue(user.photo is None)
Ejemplo n.º 11
0
 def test_remove_existing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user.remove_role(RoleType.Facilitator)
     self.assert_(not user.has_role(RoleType.Facilitator))
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assert_(user not in facilitators)
Ejemplo n.º 12
0
 def test_validate_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     self.assert_(user.validate_password('newpass') is None)
     self.assert_(isinstance(user.validate_password('a'), basestring))
Ejemplo n.º 13
0
 def test_by_uid(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
     )
     self.assert_(self.user_repository.get_by_uid(user.uid) is not None)
     self.assert_(
         self.user_repository.get_by_uid(user.uid + u'XXX') is None)
Ejemplo n.º 14
0
 def test_validate_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     self.assert_(user.validate_password('newpass') is None)
     self.assert_(isinstance(user.validate_password('a'), basestring))
Ejemplo n.º 15
0
 def test_change_password_success(self):
     user = create_user(uid=u'jdoe',
                        firstname=u'John',
                        lastname=u'Doe',
                        password=u'password')
     new_password = u'newpass'
     user.change_password(new_password)
     session.flush()
     self.assertEqual(user.password, user.encrypt_password(new_password))
Ejemplo n.º 16
0
 def test_remove_existing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user.remove_role(RoleType.Facilitator)
     self.assert_(not user.has_role(RoleType.Facilitator))
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assert_(user not in facilitators)
Ejemplo n.º 17
0
 def test_store_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     self.assertEqual(user.password, user.encrypt_password(u'password'))
     self.assert_(not user.should_change_password())
Ejemplo n.º 18
0
 def test_store_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     self.assertEqual(user.password, user.encrypt_password(u'password'))
     self.assert_(not user.should_change_password())
Ejemplo n.º 19
0
 def test_change_password_failure(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     new_password = u'a'
     with self.assertRaises(ValueError):
         user.change_password(new_password)
Ejemplo n.º 20
0
 def test_by_uid(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
     )
     self.assert_(
         self.user_repository.get_by_uid(user.uid) is not None)
     self.assert_(
         self.user_repository.get_by_uid(user.uid + u'XXX') is None)
Ejemplo n.º 21
0
 def test_reset_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     new_password = user.reset_password()
     self.assertEqual(user.password, user.encrypt_password(new_password))
     self.assert_(user.should_change_password())
Ejemplo n.º 22
0
 def test_change_password_failure(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     new_password = u'a'
     with self.assertRaises(ValueError):
         user.change_password(new_password)
Ejemplo n.º 23
0
 def test_reset_password(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password',
     )
     new_password = user.reset_password()
     self.assertEqual(user.password, user.encrypt_password(new_password))
     self.assert_(user.should_change_password())
Ejemplo n.º 24
0
 def test_change_password_success(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password'
     )
     new_password = u'newpass'
     user.change_password(new_password)
     session.flush()
     self.assertEqual(user.password, user.encrypt_password(new_password))
Ejemplo n.º 25
0
 def test_set_firstname_and_lastname(self):
     uid = u'jdoe'
     user = create_user(uid=uid)
     firstname = u'John'
     lastname = u'Doe'
     user.firstname = firstname
     user.lastname = lastname
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
Ejemplo n.º 26
0
 def test_deleting_a_user_also_remove_her_roles(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user_uid = user.uid
     user.delete()
     session.flush()
     facilitators_uids = [
         u.uid for u in self.user_repository.get_facilitators()
     ]
     self.assertFalse(user_uid in facilitators_uids)
Ejemplo n.º 27
0
 def test_set_firstname_and_lastname(self):
     uid = u'jdoe'
     user = create_user(uid=uid)
     firstname = u'John'
     lastname = u'Doe'
     user.firstname = firstname
     user.lastname = lastname
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
Ejemplo n.º 28
0
 def test_deleting_a_user_also_remove_her_roles(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user_uid = user.uid
     user.delete()
     session.flush()
     facilitators_uids = [
         u.uid for u in self.user_repository.get_facilitators()
     ]
     self.assertFalse(user_uid in facilitators_uids)
Ejemplo n.º 29
0
 def create_user(self):
     user = create_user(
         uid=u'jcdusse',
         firstname=u'Jean-Claude',
         lastname=u'Dusse',
         email=u'jean-claude.dusse@localhost',
         work_phone=u'0212345678',
         mobile_phone=u'0612345678',
         position=u'Bronzé',
         corporation=OrganizationData(label=u'PagesJaunes', type=OrganizationType(u'Corporation')),
         direction=OrganizationData(label=u'Dir. Communication', type=OrganizationType(u'Direction')),
         service=OrganizationData(label=u'Direction de la Communication', type=OrganizationType(u'Service')),
         site=OrganizationData(label=u'Sèvres', type=OrganizationType(u'Site')),
     )
     user.photo = self.create_photo()
     session.flush()
     return user
Ejemplo n.º 30
0
 def test_creation_not_enabled(self):
     uid = u'login'
     create_user(uid=uid, enabled=False)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Ejemplo n.º 31
0
 def test_creation_not_enabled(self):
     uid = u'login'
     create_user(uid=uid, enabled=False)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Ejemplo n.º 32
0
 def test_unpicklable(self):
     user = create_user(uid=u'jdoe', firstname=u'John', lastname=u'Doe')
     self.assertRaises(UnpicklableError, lambda: pickle.dumps(user))
Ejemplo n.º 33
0
 def test_remove_missing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     user.remove_role(RoleType.Developer)
     self.assert_(user.has_role(RoleType.Facilitator))
     self.assert_(not user.has_role(RoleType.Developer))
Ejemplo n.º 34
0
 def test_set_fi(self):
     user = create_user()
     fi = create_user()
     user.fi = fi
     self.assertEquals(fi, user.fi)
Ejemplo n.º 35
0
 def test_add_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     self.assert_(user.has_role(RoleType.Facilitator))
Ejemplo n.º 36
0
 def test_remove_missing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     user.remove_role(RoleType.Developer)
     self.assert_(user.has_role(RoleType.Facilitator))
     self.assert_(not user.has_role(RoleType.Developer))
Ejemplo n.º 37
0
 def test_add_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     self.assert_(user.has_role(RoleType.Facilitator))
Ejemplo n.º 38
0
 def test_set_fi(self):
     user = create_user()
     fi = create_user()
     user.fi = fi
     self.assertEquals(fi, user.fi)
Ejemplo n.º 39
0
 def test_unpicklable(self):
     user = create_user(uid=u'jdoe', firstname=u'John', lastname=u'Doe')
     self.assertRaises(UnpicklableError, lambda: pickle.dumps(user))