コード例 #1
0
    def test_get_by_id(self):
        """Get user by ID."""
        user = User('*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
コード例 #2
0
    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
コード例 #3
0
    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)
コード例 #4
0
 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