Skip to content

Commit

Permalink
fix test_default_admin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester committed Jun 9, 2024
1 parent b7b915e commit f6fe9a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create_celery(app: Flask) -> Celery:
return created


def create_or_override_default_admin(app):
def create_or_override_default_admin(app: Flask):
"""创建或覆盖默认管理员"""
from app.models.user import User

Expand Down
5 changes: 3 additions & 2 deletions tests/base/test_default_admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from app import create_app
from app.factory import init_db
from app.models.user import User
from tests import MoeTestCase

Expand All @@ -20,7 +21,7 @@ def test_reset_default_admin(self):
admin_user.save()
admin_user.reload()
self.assertEqual(admin_user.admin, False)
create_app()
init_db(create_app())
admin_user.reload()
self.assertEqual(admin_user.admin, True)
# 测试其他用户权限不受影响
Expand All @@ -34,7 +35,7 @@ def test_reset_default_admin_when_true(self):
self.assertEqual(admin_user.email, self.app.config["ADMIN_EMAIL"])
self.assertEqual(admin_user.admin, True)
self.assertEqual(user.admin, False)
create_app()
init_db(create_app())
admin_user.reload()
self.assertEqual(admin_user.admin, True)
# 测试其他用户权限不受影响
Expand Down

0 comments on commit f6fe9a1

Please sign in to comment.