def test_adding_challenge_clears_cache():
    """
    Test that when we add a challenge, it appears in our challenge list
    """
    app = create_ctfd()
    with app.app_context():
        register_user(app)

        with login_as_user(app) as client, login_as_user(
            app, name="admin", password="password"
        ) as admin:
            req = client.get("/api/v1/challenges")
            data = req.get_json()
            assert data["data"] == []

            challenge_data = {
                "name": "name",
                "category": "category",
                "description": "description",
                "value": 100,
                "state": "visible",
                "type": "standard",
            }

            r = admin.post("/api/v1/challenges", json=challenge_data)
            assert r.get_json().get("data")["id"] == 1

            req = client.get("/api/v1/challenges")
            data = req.get_json()
            assert data["data"] != []
    destroy_ctfd(app)

    Test that when we add a challenge, it appears in our challenge list
    
tests/cache/test_challenges.py