Skip to content

Commit

Permalink
feat: CDR-1550 add Robot tests for AQL Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislavploaia committed Sep 19, 2024
1 parent ac3fe16 commit 86de794
Show file tree
Hide file tree
Showing 22 changed files with 373 additions and 33 deletions.
12 changes: 3 additions & 9 deletions tests/robot/AQL_TESTS/FOLDER/FROM_FOLDER/find_all_and_by.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ Documentation CHECK AQL RESPONSE ON FOLDER FROM
... - *Postcondition:* Delete EHR using ADMIN endpoint.
Resource ../../../_resources/keywords/aql_keywords.robot

#Suite Setup Skip enable Setup 'Precondition' if AQL checks are passing !!!
#Suite Teardown Skip enable Teardown 'Admin Delete EHR For AQL' if AQL checks are passing !!!
Suite Setup Precondition #enable this keyword if AQL checks are passing !!!
Suite Teardown Admin Delete EHR For AQL #enable this keyword if AQL checks are passing !!!


*** Test Cases ***
Find All: SELECT f/uid/value, f/name/value, f/name/value, f/archetype_node_id FROM FOLDER f
[Tags] not-ready
Find All: SELECT f/uid/value, f/name/value, f/archetype_node_id FROM FOLDER f
[Documentation]
... Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-all
${query} Set Variable SELECT f/uid/value, f/name/value, f/name/value, f/archetype_node_id FROM FOLDER f
${query} Set Variable SELECT f/uid/value, f/name/value, f/archetype_node_id FROM FOLDER f
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 3
${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_find_all.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
Expand All @@ -27,7 +25,6 @@ Find All: SELECT f/uid/value, f/name/value, f/name/value, f/archetype_node_id FR
Should Be Empty ${diff} msg=DIFF DETECTED!

Find By Archetype: SELECT f/uid/value FROM FOLDER f[openEHR-EHR-FOLDER.episode_of_care.v1]
[Tags] not-ready
[Documentation]
... Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-by-archetype
${query} Set Variable SELECT f/uid/value FROM FOLDER f[openEHR-EHR-FOLDER.episode_of_care.v1]
Expand All @@ -40,7 +37,6 @@ Find By Archetype: SELECT f/uid/value FROM FOLDER f[openEHR-EHR-FOLDER.episode_o
Should Be Empty ${diff} msg=DIFF DETECTED!

Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'root1'
[Tags] not-ready
[Documentation]
... Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-by-name
${query} Set Variable SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'root1'
Expand All @@ -53,7 +49,6 @@ Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'root1'
Should Be Empty ${diff} msg=DIFF DETECTED!

Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subfolder1'
[Tags] not-ready
[Documentation]
... Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-by-name
${query} Set Variable SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subfolder1'
Expand All @@ -66,7 +61,6 @@ Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subfolder1'
Should Be Empty ${diff} msg=DIFF DETECTED!

Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subsubfolder1'
[Tags] not-ready
[Documentation]
... Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-by-name
${query} Set Variable SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subsubfolder1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS COMPOSITION - Select All
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#select-all
... - *Precondition:*
... - 1. Upload OPT; 2. Create EHR;
... 3. Create 4 compositions with conformance_ehrbase.de.v0_max.json and store their compo_ids;
... - 4. Create Directory with folder_with_compositions.json;
... - Send AQL query and compare response body with expected file content.
... - *Postcondition:* Delete EHR using ADMIN endpoint.
Resource ../../../_resources/keywords/aql_keywords.robot

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
Folder Contains Composition: SELECT c/uid/value, f/name/value FROM FOLDER f CONTAINS COMPOSITION c
[Tags] not-ready
${query} Set Variable
... SELECT c/uid/value, f/name/value FROM FOLDER f CONTAINS COMPOSITION c
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_contains_compo_select_all_tmp.json
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 12
${expected_file} Set Variable expected_folder_contains_compo_select_all.json
${expected_res_tmp} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/${expected_file}
${file_without_replaced_vars} Get File ${expected_res_tmp}
${data_replaced_vars} Replace Variables ${file_without_replaced_vars}
Create File ${temporary_file}
... ${data_replaced_vars}
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Precondition
Set Library Search Order For Tests
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid1} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid2} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid3} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid4} ${composition_short_uid}
Create Directory For AQL folder_with_compositions.json has_robot_vars=${TRUE}
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
##TODO: Implementation to be continued from https://github.com/ehrbase/conformance-testing-documentation/blob/cc2de61cd54975d1cf40be066afd88616e294aa1/FOLDER.md#folder-contains-folder
*** Settings ***
Documentation CHECK FOLDER CONTAINS FOLDER - Find All
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-all-1
... - *Precondition:* 1. Create EHR; 2. Create Directory with folder_complex_hierarchy.json;
... - Send AQL query and compare response body with expected file content.
... - *Postcondition:* Delete EHR using ADMIN endpoint.
Resource ../../../_resources/keywords/aql_keywords.robot

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
Find All: SELECT f1/uid/value, f1/name/value, f2/uid/value, f2/name/value FROM FOLDER f1 CONTAINS FOLDER f2
[Tags] not-ready
${query} Set Variable SELECT f1/uid/value, f1/name/value, f2/uid/value, f2/name/value FROM FOLDER f1 CONTAINS FOLDER f2
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 10
${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_contains_folder_find_all.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!


*** Keywords ***
Precondition
Set Library Search Order For Tests
Create EHR For AQL
Create Directory For AQL folder_complex_hierarchy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS FOLDER - Find By
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#find-by
... - *Precondition:* 1. Create EHR; 2. Create Directory with folder_complex_hierarchy.json;
... - Send AQL query and compare response body with expected file content.
... - *Postcondition:* Delete EHR using ADMIN endpoint.
Resource ../../../_resources/keywords/aql_keywords.robot
Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/folder/combinations/folder_contains_folder_find_by.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL ${ehr_id}


*** Test Cases ***
${query_nr} SELECT f2/uid/value, f2/name/value FROM FOLDER f1[${predicate1}] CONTAINS FOLDER f2[${predicate2}]
[Tags] not-ready
[Template] Execute Query
${predicate1} ${predicate2} ${expected_file} ${nr_of_results}


*** Keywords ***
Precondition
Set Library Search Order For Tests
Create EHR For AQL
Create Directory For AQL folder_complex_hierarchy.json

Execute Query
[Arguments] ${predicate1} ${predicate2} ${expected_file} ${nr_of_results}
${query} Set Variable SELECT f2/uid/value, f2/name/value FROM FOLDER f1[${predicate1}] CONTAINS FOLDER f2[${predicate2}]
Set AQL And Execute Ad Hoc Query ${query}
Log ${expected_file}
${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/${expected_file}
Length Should Be ${resp_body['rows']} ${nr_of_results}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE} ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
*** Settings ***
Documentation CHECK FOLDER MULTIPLE EHRS
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#multiple-ehrs
... - *Precondition:*
... - 1. Create EHR; 2. Create Directory with folder_complex_hierarchy.json;
... - 3. Create Directory with folder_complex_hierarchy2.json;
... - Send AQL query and compare response body with expected file content.
... - *Postcondition:* Delete EHR using ADMIN endpoint.
Resource ../../../_resources/keywords/aql_keywords.robot

Suite Setup Precondition
Suite Teardown Run Keywords Admin Delete EHR For AQL ${ehr_id1} AND
... Admin Delete EHR For AQL ${ehr_id2}


*** Test Cases ***
Multiple EHRs: SELECT e/ehr_id/value, f/uid/value FROM EHR e CONTAINS FOLDER f[openEHR-EHR-FOLDER.episode_of_care.v1,'subsubfolder1']
${query} Set Variable
... SELECT e/ehr_id/value, f/uid/value FROM EHR e CONTAINS FOLDER f[openEHR-EHR-FOLDER.episode_of_care.v1,'subsubfolder1']
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_multiple_ehrs_tmp.json
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 4
${expected_file} Set Variable expected_folder_multiple_ehrs.json
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_multiple_ehrs_tmp.json
${expected_res_tmp} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/${expected_file}
${file_without_replaced_vars} Get File ${expected_res_tmp}
${data_replaced_vars} Replace Variables ${file_without_replaced_vars}
Create File ${temporary_file}
... ${data_replaced_vars}
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Precondition
Set Library Search Order For Tests
Create EHR For AQL
Set Suite Variable ${ehr_id1} ${ehr_id}
Create Directory For AQL folder_complex_hierarchy.json
Create EHR For AQL
Set Suite Variable ${ehr_id2} ${ehr_id}
Create Directory For AQL folder_complex_hierarchy2.json
11 changes: 9 additions & 2 deletions tests/robot/_resources/keywords/aql_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,15 @@ Delete Composition For AQL
Set Suite Variable ${del_version_uid} ${del_version_uid}

Create Directory For AQL
[Arguments] ${valid_test_data_set}
${json} Load JSON From File ${FOLDERS_DATA_SETS}/${valid_test_data_set}
[Arguments] ${valid_test_data_set} ${has_robot_vars}=${FALSE}
IF '${has_robot_vars}' == '${TRUE}'
${json_str} Get File ${FOLDERS_DATA_SETS}/${valid_test_data_set}
${json_str_replaced} Replace Variables ${json_str}
${json_converted} Evaluate json.loads('''${json_str_replaced}''') json
${json} Set Variable ${json_converted}
ELSE
${json} Load JSON From File ${FOLDERS_DATA_SETS}/${valid_test_data_set}
END
Set Suite Variable ${test_data} ${json}
prepare new request session JSON
... Prefer=return=representation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "10e952ca-a5b2-4f24-8d37-59240fd37020"
},
Expand All @@ -12,7 +12,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "d936409e-901f-4994-8d33-ed104d460151"
},
Expand All @@ -24,7 +24,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "0cc504b1-4d6d-4cd5-81d9-0ef1b870edb3"
},
Expand All @@ -36,7 +36,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "3cb9efa5-fe71-49e9-a02f-d38835c27d1b"
},
Expand All @@ -50,7 +50,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "ac1e12cb-b9db-4f15-a8aa-4e62a9d97231"
},
Expand All @@ -62,7 +62,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "13661fe2-1e16-4c75-a10d-9b8040487a72"
},
Expand All @@ -74,7 +74,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "e9ae5700-d969-430a-b4f2-445e3091a901"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "10e952ca-a5b2-4f24-8d37-59240fd37020"
},
Expand All @@ -12,7 +12,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "d936409e-901f-4994-8d33-ed104d460151"
},
Expand All @@ -24,7 +24,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "04689137-90bf-456b-8afc-7c5774843919"
},
Expand All @@ -36,7 +36,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "8984f35c-8c68-41c4-af70-f4a9c2d676a0"
},
Expand All @@ -50,7 +50,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "ac1e12cb-b9db-4f15-a8aa-4e62a9d97231"
},
Expand All @@ -62,7 +62,7 @@
"folders": [
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "59bbd141-c51b-435a-9cbb-85d953ebfcd3"
},
Expand All @@ -74,7 +74,7 @@
},
{
"_type": "FOLDER",
"uuid": {
"uid": {
"_type": "HIER_OBJECT_ID",
"value": "0760c7d6-8ab9-4c6a-bd8e-f4fe3cc0e79b"
},
Expand Down
Loading

0 comments on commit 86de794

Please sign in to comment.