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)
#!/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)
#!/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)