示例#1
0
    def test_user_add_admin(self):
        admin_role = Role.query.filter_by(name='Administrator').first()
        admin_user = User.query.filter_by(role=admin_role).first()

        self.assertIsNone(admin_user)

        User.add_admin()
        admin_user2 = User.query.filter_by(role=admin_role).first()
        self.assertIsNotNone(admin_user2)
        self.assertEqual(admin_user2.role, admin_role)
示例#2
0
def deploy():
    """Run deployment tasks."""
    from flask_migrate import migrate, upgrade
    from PilosusBot.models import Role, User, Language
    from PilosusBot.utils import download_polyglot_dicts

    # generate an initial migration
    migrate()

    # migrate database to latest revision
    upgrade()

    # insert roles
    Role.insert_roles()

    # create admin
    User.add_admin()

    # insert languages
    Language.insert_basic_languages()

    # download third-party files needed for the app
    download_polyglot_dicts()