def test_get_by_id(self): """Get user by ID.""" user = User('*****@*****.**') user.save() retrieved = User.get_by_id(user.id) assert retrieved == user
def put(self, args, user_id): """Update a user.""" user = User.get_by_id(user_id) if user: user = user.update(**args) return marshal(user, resource_fields), 201 return 'User not found', 404
def test_create_user(self, testapp): """Test create user through api.""" res = testapp.post('/api/users', { 'email': '*****@*****.**', 'password': '******', }, status=201) user_id = res.json['id'] assert res.json['email'] == '*****@*****.**' assert res.json['active'] is False assert User.get_by_id(user_id)
def get(self, user_id): """Get a user.""" user = User.get_by_id(user_id) if user: return marshal(user, resource_fields), 201 return 'User not found', 404