def setup(self): self.username = '******' self.password = '******' self.email = '*****@*****.**' User.create_user(username=self.username, password=self.password, email=self.email)
def setup(self): self.username = '******' self.password = '******' self.email = '*****@*****.**' User.create_user( username=self.username, password=self.password, email=self.email )
def delete(self, id): user = User.objects(id=id).first() if user is None: status_fields = generate_status_fields(NOTFOUND) return status_fields, 404 if id in current_user.blocked_user_id: User.objects(id=current_user.id) \ .update_one(pull__blocked_user_id=id) return '', 204
def delete(self, id): user = User.objects(id=id).first() if user is None: status_fields = generate_status_fields(NOTFOUND) return status_fields, 404 if user in current_user.following: User.objects(id=current_user.id) \ .update_one(pull__following=user.to_dbref()) User.objects(id=id) \ .update_one(pull__follower=current_user.to_dbref()) return '', 204
def put(self, id): user = User.objects(id=id).first() if user is None: status_fields = generate_status_fields(NOTFOUND) return status_fields, 404 if id not in current_user.blocked_user_id: User.objects(id=current_user.id) \ .update_one(push__blocked_user_id=id) status_fields = generate_status_fields(OK) else: status_fields = generate_status_fields(EXISTING) return status_fields, 202
def put(self, id): user = User.objects(id=id).first() if user is None: status_fields = generate_status_fields(NOTFOUND) return status_fields, 404 if user not in current_user.following: User.objects(id=current_user.id) \ .update_one(push__following=user.to_dbref()) User.objects(id=id) \ .update_one(push__follower=current_user.to_dbref()) status_fields = generate_status_fields(OK) else: status_fields = generate_status_fields(EXISTING) return status_fields, 202
def setup(self): self.users = [] for x in range(3): self.users.append( User.create_user(username='******' + str(x), password='******' + str(x), email='user' + str(x) + '@a.com'))
def setup(self): self.users = [] for x in range(3): self.users.append( User.create_user( username='******' + str(x), password='******' + str(x), email='user' + str(x) + '@a.com' ) )
def delete(self, id): user = User.objects(id=id).first() if user is None: status_fields = generate_status_fields(NOTFOUND) return status_fields, 404 if user in current_user.following: current_user.update_one(pull_follwing=user) user.update_one(pull_follwer=current_user) status_fields = generate_status_fields(OK) else: status_fields = generate_status_fields(NOTFOUND) return status_fields, 204
def setup(self): c = Category.objects.create( name=u'python', description=u'描述', _slug=u'python-slug' ) Post.objects.create( title=u'标题test', content=u'内容test', category=c ) # login user self.username = '******' self.password = '******' self.email = '*****@*****.**' self.user = User.create_user( username=self.username, password=self.password, email=self.email )
def login(cls): user = User.objects.filter(email='*****@*****.**').first() if user is None: user = User.create_user('foo', '*****@*****.**', 'foobar') else: user.set_password('foobar') user.save() form = { 'email': '*****@*****.**', 'password': '******', } rv = client.post(url_for('home.login'), data=form, follow_redirects=True) assert current_user.is_authenticated() assert url_for('security.logout') in rv.data
def login(cls): user = User.objects.filter(email='*****@*****.**').first() if user is None: user = User.create_user('foo', '*****@*****.**', 'foobar') else: user.set_password('foobar') user.save() form = { 'email': '*****@*****.**', 'password': '******', } rv = client.post( url_for('home.login'), data=form, follow_redirects=True ) assert current_user.is_authenticated() assert url_for('security.logout') in rv.data
def save(self): return User.create_user( username=self.username.data, email=self.email.data, password=self.password.data )
def load_user(user_id): return User.objects(_id=user_id)