def test_teams_are_removed_after_migrating_from_team_mode_to_user_mode():
    """Are teams, and user.team relations removed when migrating from team mode to user mode"""
    app = create_ctfd()
    with app.app_context():
        with login_as_user(app, "admin") as admin:
            r = admin.patch("/api/v1/configs", json={"user_mode": "teams"})
            assert r.status_code == 200
            assert get_config("user_mode") == "teams"

            gen_team(app.db)

            assert Users.query.count() == 5
            assert Teams.query.count() == 1

            r = admin.patch("/api/v1/configs", json={"user_mode": "users"})
            assert r.status_code == 200
            assert get_config("user_mode") == "users"

            with admin.session_transaction() as sess:
                data = {
                    "user_mode": "users",
                    "submissions": "true",
                    "nonce": sess.get("nonce"),
                }
            r = admin.post("/admin/reset", data=data)
            assert r.status_code == 302

            assert Users.query.count() == 5
            assert Teams.query.count() == 0

            for user in Users.query.all():
                assert user.team is None
    destroy_ctfd(app)
Are teams, and user.team relations removed when migrating from team mode to user mode
tests/api/v1/test_config.py