示例#1
0
文件: tests.py 项目: mlrdk/backend
 def test_me(self):
     from onelove.models import User
     url = '/api/v0/me'
     data = self.get(url)
     del data['id']
     api_user = User(data)
     api_user.pk = self.me.pk
     self.assertEqual(self.me, api_user)
示例#2
0
#!/usr/bin/env python
from flask_security.utils import encrypt_password

from backend import onelove
from onelove.models import User

ctx = onelove.app.test_request_context().push()

# Create admin user
try:
    user = User.objects.get(email='*****@*****.**')
except User.DoesNotExist:
    user = User(email='*****@*****.**')
    user.password = encrypt_password('Sekrit')
    user.username = '******'
    user.active = True
    user.save()

# Create admin role
admin_role = onelove.user_datastore.find_or_create_role(
    name="admin", description="Administrator")

# Add admin user to admin role
onelove.user_datastore.add_role_to_user(user, admin_role)