From 5742aa7caff3cff57f370f0b5262c7d18630d83c Mon Sep 17 00:00:00 2001 From: Juan Manuel Lopez Date: Mon, 28 Oct 2024 16:40:46 -0300 Subject: [PATCH] =?utf8?q?Funci=C3=B3n=20para=20probar=20la=20lista=20de?= =?utf8?q?=20turnos=20tomados?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- openapi/test-api.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/openapi/test-api.sh b/openapi/test-api.sh index d12849d..9eb730e 100755 --- a/openapi/test-api.sh +++ b/openapi/test-api.sh @@ -712,6 +712,53 @@ function testTakeAppointment () { msg "[new] Pet ID (${pet_id}, ${remote_pet_id})" "${flag}" } +# -------------------------------------- +# Test the list of taken appointments +# +# @param string $1 Expected amount of taken appointments (in the list) +# @param string $2 Hour of the appointment (used if given) +# @param string $3 ID of the pet to check (used if given) +# @param string $4 ID of the veterinary (used if given) +# -------------------------------------- +function testListAppointment () { + local amount="${1}" + local appointment="${2}" + local pet_id="${3}" + local vet_id="${4}" + local flag='' + + echo '========================================' + msg 'Test the list of taken appointments' + + elementGet '/turno' + + local remote_amount=$(countItemsInJsonList "${CURL_RESPONSE_DATA}") + flag=$( (($remote_amount == $amount)) && echo "s" || echo "f" ) + msg "[list] Amount of taken appointments (${amount}, ${remote_amount})" "${flag}" + + if [[ "${appointment}" ]]; then + local json=$(searchByKeyValue "${CURL_RESPONSE_DATA}" 'turno' "${appointment}") + + if [[ "${json}" ]]; then + msg "[list] Appointment found ('${appointment}')" "s" + + if [[ "${pet_id}" ]]; then + local remote_pet_id=$(getValueFromJson "${json}" 'mascota_id') + flag=$([[ "${remote_pet_id}" == "${pet_id}" ]] && echo "s" || echo "f") + msg "[list] Appointment pet ID (${pet_id}, ${remote_pet_id})" "${flag}" + fi + + if [[ "${vet_id}" ]]; then + local remote_vet_id=$(getValueFromJson "${json}" 'veterinario_id') + flag=$([[ "${remote_vet_id}" == "${vet_id}" ]] && echo "s" || echo "f") + msg "[list] Appointment veterinary ID (${vet_id}, ${remote_vet_id})" "${flag}" + fi + else + msg "[list] Appointment not found ('${appointment}')" "f" + fi + fi +} + # ==================================================================== # Remove and create DDBB -- 2.11.4.GIT