Example #1
0
    def test_add_checkpoint(self):
        """
        Tests the add_checkpoint() functionality by creating a mock checkpoint and saving
        it to a mock user
        """
        #create test user
        test_fb_user = self.create_facebook_test_user()
        fb_user, user = save_user(test_fb_user["access_token"], "someauthcode")
        
        #create mock checkpoint
        mock_cp_data = CheckpointTests.mock_checkpoint_data(user.id)
        checkpoint = add_checkpoint(*mock_cp_data)

        #asserts
        assert not get_checkpoint(checkpoint.id) is None
Example #2
0
def del_user_checkpoint():
    """
    (DELETE: user_checkpoint)
    """
    #req args
    user_id = request.args.get("user_id")
    signature = request.args.get("signature")
    checkpoint_id = request.args.get("checkpoint_id")
    
    if not authorize("delete", "user_checkpoint", user_id, signature):
        return authorization_fail()
    
    #generated vars
    user_obj = get_user(user_id)
    checkpoint_obj = get_checkpoint(checkpoint_id)
    
    remove_checkpoint_from_user(user_obj, checkpoint_obj)
    
    return jsonify({"status": "ok",
                    })
Example #3
0
def add_user_checkpoint():
    """
    (PUT: user_checkpoint)
    """
    #req args
    user_id = request.form.get("user_id")
    signature = request.form.get("signature")
    checkpoint_id = request.form.get("checkpoint_id")
    
    if not authorize("put", "user_checkpoint", user_id, signature):
        return authorization_fail()
    
    #generated
    user_obj = get_user(user_id)
    checkpoint_obj = get_checkpoint(checkpoint_id)
    
    user_checkpoint = add_checkpoint_to_user(user_obj, checkpoint_obj)
    
    return jsonify({"status": "ok",
                    "user_checkpoint_id": user_checkpoint.id,
                    })