예제 #1
0
    def test_get_by_id(self):
        """Get user by ID."""
        user = User(username='******', email='*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
예제 #2
0
def create_admin(username, first_name, last_name, email, password):
    """ Create an admin user. """
    admin = User(username,
                 email,
                 password=password,
                 first_name=first_name,
                 last_name=last_name,
                 active=True,
                 is_admin=True)
    db.session.add(admin)
    db.session.commit()
    click.echo(f'Admin user: {username} created.')
예제 #3
0
 def test_password_is_nullable(self):
     """Test null password."""
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert user.password is None
예제 #4
0
 def test_created_at_defaults_to_datetime(self):
     """Test creation date."""
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert bool(user.created_at)
     assert isinstance(user.created_at, dt.datetime)