Skip to content

Commit

Permalink
feat: CDR-1550 add Robot tests based on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislavploaia committed Sep 19, 2024
1 parent 86de794 commit 2af3c89
Show file tree
Hide file tree
Showing 23 changed files with 746 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS COMPOSITION - Folder in Folder
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#folder-in-folder
... - *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


*** Variables ***
${q} SELECT c/uid/value FROM FOLDER f1[openEHR-EHR-FOLDER.episode_of_care.v1] CONTAINS FOLDER f2[openEHR-EHR-FOLDER.episode_of_care.v1] CONTAINS COMPOSITION c


*** Test Cases ***
Folder In Folder: ${q}
[Tags] not-ready
Set Test Variable ${query} ${q}
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 1
${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_folder_in_folder.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_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!


*** 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
@@ -0,0 +1,45 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS COMPOSITION - Multiple Compositions in a Folder
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#multi-comp-in-a-folder
... - *Precondition:*
... - 1. Upload OPT; 2. Create EHR and store ehr_id1;
... - 3. Create 2 compositions with conformance_ehrbase.de.v0_max.json and store their compo_ids;
... - 4. Create Directory with folder_multi_compositions.json;
... - 5. Create 1 composition with conformance_ehrbase.de.v0_max.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

*** Variables ***
${q} SELECT c/uid/value FROM FOLDER f CONTAINS COMPOSITION c


*** Test Cases ***
Multi Comp In A Folder: ${q}
[Tags] not-ready
Set Test Variable ${query} ${q}
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 2
${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_multi_compo_in_folder.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
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}
Create Directory For AQL folder_multi_compositions.json has_robot_vars=${TRUE}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS COMPOSITION - Over multiple EHRs
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#over-multiple-ehrs
... - *Precondition:*
... - 1. Upload OPT; 2. Create EHR and store ehr_id1;
... - 3. Create 4 compositions with conformance_ehrbase.de.v0_max.json and store their compo_ids;
... - 4. Create Directory with folder_with_compositions.json;
... - 5. Create 1 composition with conformance_ehrbase.de.v0_max.json;
... - 6. Create EHR and store ehr_id2;
... - 7. Create 4 compositions with conformance_ehrbase.de.v0_max.json and store their compo_ids;
... - 8. Create Directory with folder_with_compositions.json;
... - 9. Create 1 composition with conformance_ehrbase.de.v0_max.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}


*** Variables ***
${q} SELECT e/ehr_id/value, c/uid/value FROM EHR e CONTAINS FOLDER f CONTAINS COMPOSITION c WHERE f/name/value = 'subsubsubfolder1'


*** Test Cases ***
Over Multiple EHRs: ${q}
[Tags] not-ready
Set Test Variable ${query} ${q}
${temporary_file} Set Variable
... ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_over_multiple_ehrs_tmp.json
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 2
${expected_file} Set Variable expected_contains_compo_over_multiple_ehrs.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}
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result} exclude_paths=${exclude_paths}
... 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
Set Suite Variable ${ehr_id1} ${ehr_id}
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}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
##
Create EHR For AQL
Set Suite Variable ${ehr_id2} ${ehr_id}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid1b} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid2b} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid3b} ${composition_short_uid}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Set Suite Variable ${c_uid4b} ${composition_short_uid}
Create Directory For AQL folder_with_compositions1.json has_robot_vars=${TRUE}
Commit Composition For AQL conformance_ehrbase.de.v0_max.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
*** Settings ***
Documentation CHECK FOLDER CONTAINS COMPOSITION - Select by name
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#select-by-name
... - *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
Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/folder/combinations/folder_contains_compo_select_by_name.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
${query_nr} SELECT c/uid/value FROM FOLDER f CONTAINS COMPOSITION c WHERE f/name/value = '${name}'
[Tags] not-ready
[Template] Execute Query
${name} ${expected_file} ${nr_of_results}



*** 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}

Execute Query
[Arguments] ${name} ${expected_file} ${nr_of_results}
${query} Set Variable SELECT c/uid/value FROM FOLDER f CONTAINS COMPOSITION c WHERE f/name/value = '${name}'
${expected_file_with_replaced_vars} Set Variable
... ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_contains_compo_select_by_name_tmp.json
Set AQL And Execute Ad Hoc Query ${query}
${expected_res_tmp} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/${expected_file}
${file_without_replaced_vars} Get Binary File ${expected_res_tmp}
${data_replaced_vars} Replace Variables ${file_without_replaced_vars}
Create Binary File ${expected_file_with_replaced_vars}
... ${data_replaced_vars}
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_file_with_replaced_vars}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE} ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${expected_file_with_replaced_vars}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
*** Settings ***
Documentation CHECK SELECT PATHS IN FOLDER
... - Covers: https://github.com/ehrbase/conformance-testing-documentation/blob/main/FOLDER.md#select-paths-in-folder
... - *Precondition:*
... - 1. Create EHR;
... - 2. Create Directory with folder_details.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/select_paths_in_folder.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
${query_nr} SELECT ${path} FROM FOLDER f
[Tags] not-ready
[Template] Execute Query
${path} ${expected_file} ${nr_of_results}


*** Keywords ***
Precondition
Set Library Search Order For Tests
Create EHR For AQL
Create Directory For AQL folder_details.json has_robot_vars=${FALSE}

Execute Query
[Arguments] ${path} ${expected_file} ${nr_of_results}
${query} Set Variable SELECT ${path} FROM FOLDER f
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'] root['rows'][0][0]['uid']
... root['rows'][0][0]['folders'][0]['uid'] root['rows'][1][0]['uid']
${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,88 @@
{
"_type": "FOLDER",
"uuid": {
"_type": "HIER_OBJECT_ID",
"value": "10e952ca-a5b2-4f24-8d37-59240fd37020"
},
"name": {
"_type": "DV_TEXT",
"value": "root1"
},
"archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "Tree"
},
"archetype_node_id": "at0003",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "text"
},
"archetype_node_id": "at0004",
"value": {
"_type": "DV_TEXT",
"value": "value2"
}
}
]
},
"folders": [
{
"_type": "FOLDER",
"uuid": {
"_type": "HIER_OBJECT_ID",
"value": "d936409e-901f-4994-8d33-ed104d460151"
},
"name": {
"_type": "DV_TEXT",
"value": "subfolder1"
},
"archetype_node_id": "openEHR-EHR-FOLDER.episode_of_care.v1",
"items": [
{
"id": {
"_type": "HIER_OBJECT_ID",
"value": "7c0a9df0-564f-4f34-8e65-92586c64ef56"
},
"namespace": "my.system.id",
"type": "VERSIONED_COMPOSITION"
},
{
"id": {
"_type": "HIER_OBJECT_ID",
"value": "c68131a3-72da-41fe-8d11-c4fccfd2d2d0"
},
"namespace": "my.system.id",
"type": "VERSIONED_COMPOSITION"
}
],
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "Tree"
},
"archetype_node_id": "at0003",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "text"
},
"archetype_node_id": "at0004",
"value": {
"_type": "DV_TEXT",
"value": "value1"
}
}
]
}
}
]
}
Loading

0 comments on commit 2af3c89

Please sign in to comment.