def test_api_users_post_admin_duplicate_information():
    """Can an admin create a user with duplicate information"""
    app = create_ctfd()
    with app.app_context():
        register_user(app)
        with login_as_user(app, "admin") as client:
            # Duplicate email
            r = client.post(
                "/api/v1/users",
                json={
                    "name": "user2",
                    "email": "user@examplectf.com",
                    "password": "password",
                },
            )
            resp = r.get_json()
            assert r.status_code == 400
            assert resp["errors"]["email"]
            assert resp["success"] is False
            assert Users.query.count() == 2

            # Duplicate user
            r = client.post(
                "/api/v1/users",
                json={
                    "name": "user",
                    "email": "user2@examplectf.com",
                    "password": "password",
                },
            )
            resp = r.get_json()
            assert r.status_code == 400
            assert resp["errors"]["name"]
            assert resp["success"] is False
            assert Users.query.count() == 2
    destroy_ctfd(app)
Can an admin create a user with duplicate information
tests/api/v1/test_users.py