def test__unit__unicode__ok__no_display_name(self): email = '*****@*****.**' user = User() user.email = email assert user.__unicode__() == email
def test_unit__unicode__ok__nominal_case(self): name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email assert user.__unicode__() == name
def test_unit__repr__ok__nominal_case(self): name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email assert user.__repr__( ) == "<User: email='*****@*****.**', display='Damien'>" # nopep8
def test_unit__validate_password__false__null_password(self): # Check bug #70 fixed # http://tracim.org/workspaces/4/folders/5/threads/70 name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email assert user.validate_password('') is False
def test_null_password(self): # Check bug #70 fixed # http://tracim.org/workspaces/4/folders/5/threads/70 name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email eq_(False, user.validate_password(None))
def test_unit__validate_password__false__bad_password(self): """ Check if validate_password can correctly check if password is an uncorrect correct one """ name = 'Damien' email = '*****@*****.**' password = '******' user = User() user.display_name = name user.email = email user.password = password assert user.validate_password('uncorrect_password') is False
def create_user(self, email=None, groups=[], save_now=False) -> User: user = User() if email: user.email = email for group in groups: user.groups.append(group) self._session.add(user) if save_now: self._session.flush() return user
def test__unit__validate_password__ok__nominal_case(self): """ Check if validate_password can correctly check if password i the correct one """ name = 'Damien' email = '*****@*****.**' password = '******' user = User() user.display_name = name user.email = email user.password = password assert user.validate_password(password) is True
def test_unit__password__ok__nominal_case(self): """ Check if password can be set and hashed password can be retrieve. Verify if hashed password is not same as password. """ name = 'Damien' email = '*****@*****.**' password = '******' user = User() user.display_name = name user.email = email assert user._password is None user.password = password assert user._password is not None assert user._password != password assert user.password == user._password
def update( self, user: User, name: str=None, email: str=None, do_save=True, timezone: str='', ): if name is not None: user.display_name = name if email is not None: user.email = email user.timezone = timezone if do_save: self.save(user)
def test_unit__create__ok__nominal_case(self): self.session.flush() transaction.commit() name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email self.session.add(user) self.session.flush() transaction.commit() new_user = self.session.query(User).filter( User.display_name == name).one() # nopep8 assert new_user.display_name == name assert new_user.email == email assert new_user.email_address == email
def create_minimal_user(self, email, groups=[], save_now=False) -> User: """Previous create_user method""" user = User() email_exist = self._check_email(email) if not email_exist: raise EmailValidationFailed( 'Email given form {} is uncorrect'.format(email)) # nopep8 user.email = email user.display_name = email.split('@')[0] for group in groups: user.groups.append(group) self._session.add(user) if save_now: self._session.flush() return user
def test_create(self): self.session.flush() transaction.commit() name = 'Damien' email = '*****@*****.**' user = User() user.display_name = name user.email = email self.session.add(user) self.session.flush() transaction.commit() new_user = self.session.query(User).filter( User.display_name == name).one() eq_(new_user.display_name, name) eq_(new_user.email, email) eq_(new_user.email_address, email)
def update( self, user: User, name: str = None, email: str = None, password: str = None, timezone: str = None, groups: typing.Optional[typing.List[Group]] = None, do_save=True, ) -> User: if name is not None: user.display_name = name if email is not None: email_exist = self._check_email(email) if not email_exist: raise EmailValidationFailed( 'Email given form {} is uncorrect'.format(email)) # nopep8 user.email = email if password is not None: user.password = password if timezone is not None: user.timezone = timezone if groups is not None: # INFO - G.M - 2018-07-18 - Delete old groups for group in user.groups: if group not in groups: user.groups.remove(group) # INFO - G.M - 2018-07-18 - add new groups for group in groups: if group not in user.groups: user.groups.append(group) if do_save: self.save(user) return user