def test_get_hashed_percentage_for_object_ids_should_be_evenly_distributed():  # type: ignore[no-untyped-def]
    """
    This test checks if the percentage value returned by the helper function returns
    evenly distributed values.

    Note that since it's technically random, it's not guaranteed to pass every time,
    however, it should pass 99/100 times. It will likely be more accurate by increasing
    the test_sample value and / or decreasing the num_test_buckets value.
    """
    test_sample = 500  # number of ids to sample in each list
    num_test_buckets = 50  # split the sample into 'buckets' to check that the values are evenly distributed
    test_bucket_size = int(test_sample / num_test_buckets)
    error_factor = 0.1

    # Given
    object_id_pairs = itertools.product(range(test_sample), range(test_sample))

    # When
    values = sorted(
        get_hashed_percentage_for_object_ids(pair) for pair in object_id_pairs
    )

    # Then
    for i in range(num_test_buckets):
        bucket_start = i * test_bucket_size
        bucket_end = (i + 1) * test_bucket_size
        bucket_value_limit = min(
            (i + 1) / num_test_buckets + error_factor * ((i + 1) / num_test_buckets),
            1,
        )

        assert all(
            [value <= bucket_value_limit for value in values[bucket_start:bucket_end]]
        )

    This test checks if the percentage value returned by the helper function returns
    evenly distributed values.

    Note that since it's technically random, it's not guaranteed to pass every time,
    however, it should pass 99/100 times. It will likely be more accurate by increasing
    the test_sample value and / or decreasing the num_test_buckets value.
    
api/tests/unit/environments/identities/test_unit_identities_helpers.py