# -*- coding: utf-8 -*-

"""
* Name:         interactive-clustering-gui/tests/test_get_api_projects_constraints.py
* Description:  Unittests for `app` module on the `GET /api/projects/{project_id}/constraints` route.
* Author:       Erwan Schild
* Created:      22/02/2022
* Licence:      CeCILL (https://cecill.info/licences.fr.html)
"""

# ==============================================================================
# IMPORT PYTHON DEPENDENCIES
# ==============================================================================

import pytest

from tests.dummies_utils import create_dummy_projects

# ==============================================================================
# test_ko_not_found
# ==============================================================================


@pytest.mark.asyncio()
async def test_ko_not_found(async_client):
    """
    Test the `GET /api/projects/{project_id}/constraints` route with not existing project.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(url="/api/projects/UNKNOWN_PROJECT/constraints")
    assert response_get.status_code == 404
    assert response_get.json() == {
        "detail": "The project with id 'UNKNOWN_PROJECT' doesn't exist.",
    }


# ==============================================================================
# test_ok_default
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_default(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints")
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "id",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_with_hidden
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_with_hidden(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?without_hidden_constraints=False"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True in list_of_hidden_marks
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(11,14)": {
                "data": {"id_1": "11", "id_2": "14"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": True,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(14,9)": {
                "data": {"id_1": "14", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": True,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": False,
            "sorted_by": "id",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_id
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_id(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=id"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_ids = list(response_get.json()["constraints"].keys())
    assert list_of_ids == sorted(list_of_ids)
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "id",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_text
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_text(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=text"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "text",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_constraint_type
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_constraint_type(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=constraint_type"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_constraint_types = [
        (constraint_value["constraint_type"] if constraint_value["constraint_type"] is not None else "")
        for constraint_value in response_get.json()["constraints"].values()
    ]
    assert list_of_constraint_types == sorted(list_of_constraint_types, reverse=True)
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "constraint_type",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_date_of_update
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_date_of_update(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=date_of_update"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "date_of_update",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_iteration_of_sampling
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_iteration_of_sampling(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "2d_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/2d_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=iteration_of_sampling"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_iteration_of_sampling = [
        constraint_value["iteration_of_sampling"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert list_of_iteration_of_sampling == sorted(list_of_iteration_of_sampling)
    assert response_get.json() == {
        "project_id": "2d_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(13,15)": {
                "data": {"id_1": "13", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(17,23)": {
                "data": {"id_1": "17", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,13)": {
                "data": {"id_1": "12", "id_2": "13"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,15)": {
                "data": {"id_1": "10", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(21,23)": {
                "data": {"id_1": "21", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,5)": {
                "data": {"id_1": "11", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,5)": {
                "data": {"id_1": "1", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,8)": {
                "data": {"id_1": "15", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(19,23)": {
                "data": {"id_1": "19", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,15)": {
                "data": {"id_1": "12", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(4,5)": {
                "data": {"id_1": "4", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,13)": {
                "data": {"id_1": "10", "id_2": "13"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(5,9)": {
                "data": {"id_1": "5", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,3)": {
                "data": {"id_1": "10", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,9)": {
                "data": {"id_1": "15", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,9)": {
                "data": {"id_1": "13", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,4)": {
                "data": {"id_1": "11", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,4)": {
                "data": {"id_1": "10", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,8)": {
                "data": {"id_1": "13", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,6)": {
                "data": {"id_1": "15", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,6)": {
                "data": {"id_1": "13", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,3)": {
                "data": {"id_1": "11", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,15)": {
                "data": {"id_1": "11", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,13)": {
                "data": {"id_1": "11", "id_2": "13"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,3)": {
                "data": {"id_1": "12", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(3,9)": {
                "data": {"id_1": "3", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(22,23)": {
                "data": {"id_1": "22", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,11)": {
                "data": {"id_1": "1", "id_2": "11"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,7)": {
                "data": {"id_1": "11", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,12)": {
                "data": {"id_1": "1", "id_2": "12"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,9)": {
                "data": {"id_1": "1", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,2)": {
                "data": {"id_1": "11", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,10)": {
                "data": {"id_1": "1", "id_2": "10"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,7)": {
                "data": {"id_1": "12", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(7,9)": {
                "data": {"id_1": "7", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(18,23)": {
                "data": {"id_1": "18", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,7)": {
                "data": {"id_1": "10", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,2)": {
                "data": {"id_1": "12", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(20,23)": {
                "data": {"id_1": "20", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(2,9)": {
                "data": {"id_1": "2", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,2)": {
                "data": {"id_1": "10", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,11)": {
                "data": {"id_1": "0", "id_2": "11"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,15)": {
                "data": {"id_1": "0", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,15)": {
                "data": {"id_1": "1", "id_2": "15"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(6,8)": {
                "data": {"id_1": "6", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(6,9)": {
                "data": {"id_1": "6", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,6)": {
                "data": {"id_1": "11", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,6)": {
                "data": {"id_1": "12", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,3)": {
                "data": {"id_1": "15", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,7)": {
                "data": {"id_1": "15", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,5)": {
                "data": {"id_1": "0", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,8)": {
                "data": {"id_1": "0", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,9)": {
                "data": {"id_1": "0", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,10)": {
                "data": {"id_1": "0", "id_2": "10"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,12)": {
                "data": {"id_1": "0", "id_2": "12"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,13)": {
                "data": {"id_1": "0", "id_2": "13"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,8)": {
                "data": {"id_1": "1", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,13)": {
                "data": {"id_1": "1", "id_2": "13"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(2,5)": {
                "data": {"id_1": "2", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(2,8)": {
                "data": {"id_1": "2", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(3,5)": {
                "data": {"id_1": "3", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(3,8)": {
                "data": {"id_1": "3", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(4,8)": {
                "data": {"id_1": "4", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(4,9)": {
                "data": {"id_1": "4", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(5,6)": {
                "data": {"id_1": "5", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(5,7)": {
                "data": {"id_1": "5", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(5,8)": {
                "data": {"id_1": "5", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(7,8)": {
                "data": {"id_1": "7", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,6)": {
                "data": {"id_1": "10", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,4)": {
                "data": {"id_1": "12", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,5)": {
                "data": {"id_1": "12", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,2)": {
                "data": {"id_1": "13", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,3)": {
                "data": {"id_1": "13", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,4)": {
                "data": {"id_1": "13", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,5)": {
                "data": {"id_1": "13", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,7)": {
                "data": {"id_1": "13", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,2)": {
                "data": {"id_1": "15", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,4)": {
                "data": {"id_1": "15", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,5)": {
                "data": {"id_1": "15", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,5)": {
                "data": {"id_1": "10", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,23)": {
                "data": {"id_1": "11", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,19)": {
                "data": {"id_1": "15", "id_2": "19"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,3)": {
                "data": {"id_1": "23", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(17,5)": {
                "data": {"id_1": "17", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(20,5)": {
                "data": {"id_1": "20", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,17)": {
                "data": {"id_1": "13", "id_2": "17"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(18,5)": {
                "data": {"id_1": "18", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,23)": {
                "data": {"id_1": "13", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,9)": {
                "data": {"id_1": "23", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,5)": {
                "data": {"id_1": "23", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,4)": {
                "data": {"id_1": "23", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,22)": {
                "data": {"id_1": "15", "id_2": "22"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,8)": {
                "data": {"id_1": "16", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(19,5)": {
                "data": {"id_1": "19", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,2)": {
                "data": {"id_1": "16", "id_2": "2"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,23)": {
                "data": {"id_1": "1", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(21,5)": {
                "data": {"id_1": "21", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,18)": {
                "data": {"id_1": "15", "id_2": "18"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,21)": {
                "data": {"id_1": "16", "id_2": "21"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(22,5)": {
                "data": {"id_1": "22", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,7)": {
                "data": {"id_1": "23", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,16)": {
                "data": {"id_1": "10", "id_2": "16"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,16)": {
                "data": {"id_1": "0", "id_2": "16"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,20)": {
                "data": {"id_1": "13", "id_2": "20"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,23)": {
                "data": {"id_1": "16", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,3)": {
                "data": {"id_1": "16", "id_2": "3"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,18)": {
                "data": {"id_1": "13", "id_2": "18"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,6)": {
                "data": {"id_1": "16", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(2,23)": {
                "data": {"id_1": "2", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,16)": {
                "data": {"id_1": "12", "id_2": "16"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,19)": {
                "data": {"id_1": "13", "id_2": "19"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,6)": {
                "data": {"id_1": "23", "id_2": "6"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,9)": {
                "data": {"id_1": "16", "id_2": "9"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,20)": {
                "data": {"id_1": "15", "id_2": "20"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,4)": {
                "data": {"id_1": "16", "id_2": "4"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,22)": {
                "data": {"id_1": "13", "id_2": "22"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,19)": {
                "data": {"id_1": "16", "id_2": "19"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,17)": {
                "data": {"id_1": "15", "id_2": "17"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,21)": {
                "data": {"id_1": "15", "id_2": "21"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,20)": {
                "data": {"id_1": "16", "id_2": "20"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(12,23)": {
                "data": {"id_1": "12", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,18)": {
                "data": {"id_1": "16", "id_2": "18"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(13,21)": {
                "data": {"id_1": "13", "id_2": "21"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(23,8)": {
                "data": {"id_1": "23", "id_2": "8"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(1,16)": {
                "data": {"id_1": "1", "id_2": "16"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,5)": {
                "data": {"id_1": "16", "id_2": "5"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,22)": {
                "data": {"id_1": "16", "id_2": "22"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(11,16)": {
                "data": {"id_1": "11", "id_2": "16"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(0,23)": {
                "data": {"id_1": "0", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,7)": {
                "data": {"id_1": "16", "id_2": "7"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(16,17)": {
                "data": {"id_1": "16", "id_2": "17"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(10,23)": {
                "data": {"id_1": "10", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
            "(15,23)": {
                "data": {"id_1": "15", "id_2": "23"},
                "constraint_type": None,
                "constraint_type_previous": [],
                "is_hidden": False,
                "to_annotate": True,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": None,
                "iteration_of_sampling": 2,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "iteration_of_sampling",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_to_annotate
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_to_annotate(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=to_annotate"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_to_annotate = [
        constraint_value["to_annotate"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert list_of_to_annotate == sorted(list_of_to_annotate, reverse=True)
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "to_annotate",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_to_review
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_to_review(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_by=to_review"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_to_review = [
        constraint_value["to_review"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert list_of_to_review == sorted(list_of_to_review, reverse=True)
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "to_review",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_to_fix_conflict
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_to_fix_conflict(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS/constraints?sorted_by=to_fix_conflict"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    list_of_to_fix_conflict = [
        constraint_value["to_fix_conflict"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True in list_of_to_fix_conflict
    assert list_of_to_fix_conflict == sorted(list_of_to_fix_conflict, reverse=True)
    assert response_get.json() == {
        "project_id": "1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS",
        "constraints": {
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": True,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None, "MUST_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545553.46324,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "to_fix_conflict",
            "sorted_reverse": False,
        },
    }


# ==============================================================================
# test_ok_by_sorted_reverse
# ==============================================================================


@pytest.mark.asyncio()
async def test_ok_by_sorted_reverse(async_client, tmp_path):
    """
    Test the `GET /api/projects/{project_id}/constraints` route.

    Arguments:
        async_client: Fixture providing an HTTP client, declared in `conftest.py`.
        tmp_path: The temporary path given for this test, declared in `conftest.py`.
    """
    # Assert HTTP client is created.
    assert async_client

    # Create dummy projects.
    create_dummy_projects(
        tmp_path=tmp_path,
        list_of_dummy_project_ids=[
            "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        ],
    )

    # Assert route `GET /api/projects/{project_id}/constraints` works.
    response_get = await async_client.get(
        url="/api/projects/1l_ANNOTATION_WITH_UPTODATE_MODELIZATION/constraints?sorted_reverse=True"
    )
    assert response_get.status_code == 200
    list_of_hidden_marks = [
        constraint_value["is_hidden"] for constraint_value in response_get.json()["constraints"].values()
    ]
    assert True not in list_of_hidden_marks
    assert response_get.json() == {
        "project_id": "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
        "constraints": {
            "(8,9)": {
                "data": {"id_1": "8", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543496.268081,
                "iteration_of_sampling": 1,
            },
            "(4,7)": {
                "data": {"id_1": "4", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "MUST_LINK", "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "Même intention (gestion carte virtuelle).",
                "date_of_update": 1657546214.538204,
                "iteration_of_sampling": 1,
            },
            "(4,6)": {
                "data": {"id_1": "4", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545344.703469,
                "iteration_of_sampling": 1,
            },
            "(22,8)": {
                "data": {"id_1": "22", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543535.036781,
                "iteration_of_sampling": 1,
            },
            "(22,6)": {
                "data": {"id_1": "22", "id_2": "6"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543454.547808,
                "iteration_of_sampling": 1,
            },
            "(21,22)": {
                "data": {"id_1": "21", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543471.789491,
                "iteration_of_sampling": 1,
            },
            "(20,22)": {
                "data": {"id_1": "20", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543457.282708,
                "iteration_of_sampling": 1,
            },
            "(2,4)": {
                "data": {"id_1": "2", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543493.240642,
                "iteration_of_sampling": 1,
            },
            "(19,22)": {
                "data": {"id_1": "19", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543503.891212,
                "iteration_of_sampling": 1,
            },
            "(18,8)": {
                "data": {"id_1": "18", "id_2": "8"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545348.247546,
                "iteration_of_sampling": 1,
            },
            "(18,22)": {
                "data": {"id_1": "18", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543537.76648,
                "iteration_of_sampling": 1,
            },
            "(17,22)": {
                "data": {"id_1": "17", "id_2": "22"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543500.755786,
                "iteration_of_sampling": 1,
            },
            "(15,16)": {
                "data": {"id_1": "15", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545325.795985,
                "iteration_of_sampling": 1,
            },
            "(13,16)": {
                "data": {"id_1": "13", "id_2": "16"},
                "constraint_type": "CANNOT_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545332.124029,
                "iteration_of_sampling": 1,
            },
            "(12,9)": {
                "data": {"id_1": "12", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None, "CANNOT_LINK"],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543315.242459,
                "iteration_of_sampling": 1,
            },
            "(11,12)": {
                "data": {"id_1": "11", "id_2": "12"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543475.46025,
                "iteration_of_sampling": 1,
            },
            "(10,9)": {
                "data": {"id_1": "10", "id_2": "9"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543432.412055,
                "iteration_of_sampling": 1,
            },
            "(10,11)": {
                "data": {"id_1": "10", "id_2": "11"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543487.605554,
                "iteration_of_sampling": 1,
            },
            "(1,7)": {
                "data": {"id_1": "1", "id_2": "7"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543507.347849,
                "iteration_of_sampling": 1,
            },
            "(1,6)": {
                "data": {"id_1": "1", "id_2": "6"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": True,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543490.330898,
                "iteration_of_sampling": 1,
            },
            "(1,3)": {
                "data": {"id_1": "1", "id_2": "3"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543464.28536,
                "iteration_of_sampling": 1,
            },
            "(1,2)": {
                "data": {"id_1": "1", "id_2": "2"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [None],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657543438.389156,
                "iteration_of_sampling": 1,
            },
            "(0,4)": {
                "data": {"id_1": "0", "id_2": "4"},
                "constraint_type": "MUST_LINK",
                "constraint_type_previous": [
                    None,
                    "MUST_LINK",
                    None,
                    "MUST_LINK",
                    None,
                    None,
                    None,
                    "MUST_LINK",
                    "MUST_LINK",
                    "CANNOT_LINK",
                ],
                "is_hidden": False,
                "to_annotate": False,
                "to_review": False,
                "to_fix_conflict": False,
                "comment": "",
                "date_of_update": 1657545443.884245,
                "iteration_of_sampling": 1,
            },
        },
        "parameters": {
            "without_hidden_constraints": True,
            "sorted_by": "id",
            "sorted_reverse": True,
        },
    }
