Skip to content

Commit

Permalink
fix: CDR-1659 use system_id_with_tenant as variable to provide tnt na…
Browse files Browse the repository at this point in the history
…me in system_id - AQL FOLDER
  • Loading branch information
vladislavploaia committed Nov 14, 2024
1 parent 82b2221 commit cf36c23
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 135 deletions.
18 changes: 11 additions & 7 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 @@ -16,10 +16,12 @@ Find All: SELECT f/uid/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
${expected_result_file} 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
... ${resp_body_actual} ${expected_result} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
Expand All @@ -42,10 +44,12 @@ Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'root1'
${query} Set Variable SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'root1'
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_find_by_name_root1.json
${expected_result_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_find_by_name_root1.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}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
Should Be Empty ${diff} msg=DIFF DETECTED!

Find By Name: SELECT f/uid/value FROM FOLDER f WHERE f/name/value = 'subfolder1'
Expand Down Expand Up @@ -90,4 +94,4 @@ Find By Folder Id: SELECT f/name/value, f/uid/value FROM FOLDER f WHERE f/uid/va
Precondition
Set Library Search Order For Tests
Create EHR For AQL
Create Directory For AQL folder_simple_hierarchy.json
Create Directory For AQL folder_simple_hierarchy.json
15 changes: 5 additions & 10 deletions tests/robot/AQL_TESTS/FOLDER/FROM_FOLDER/find_by_ehr_id.robot
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ Find By EHR Id: SELECT e/ehr_id/value, f/uid/value FROM EHR e CONTAINS FOLDER f
${query} Set Variable SELECT e/ehr_id/value, f/uid/value FROM EHR e CONTAINS FOLDER f WHERE e/ehr_id/value = '${ehr_id1}'
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 3
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_find_by_ehr_id_tmp.json
${expected_file} Set Variable expected_folder_find_by_ehr_id.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}
${expected_result_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_find_by_ehr_id.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@ ${q} SELECT c/uid/value FROM FOLDER f1[openEHR-EHR-FOLDER.episode_of_care.v1]
Folder In Folder: ${q}
Set Test Variable ${query} ${q}
Set AQL And Execute Ad Hoc Query ${query}
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_folder_in_folder_tmp.json
Length Should Be ${resp_body['rows']} 1
${expected_file} Set Variable expected_contains_compo_folder_in_folder.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}
${expected_result_file} 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} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ ${q} SELECT c/uid/value FROM FOLDER f CONTAINS COMPOSITION c
Multi Comp In A Folder: ${q}
Set Test Variable ${query} ${q}
Set AQL And Execute Ad Hoc Query ${query}
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_multi_compo_in_folder_tmp.json
Length Should Be ${resp_body['rows']} 2
${expected_file} Set Variable expected_contains_compo_multi_compo_in_folder.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}
${expected_result_file} 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} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ SELECT e/ehr_id/value, f/uid/value, c/uid/value FROM EHR e CONTAINS FOLDER f CON
... SELECT e/ehr_id/value, f/uid/value, c/uid/value FROM EHR e CONTAINS FOLDER f CONTAINS COMPOSITION c WHERE e/ehr_id/value = '${ehr_id2}' AND f/uid/value = '70939d97-8add-4419-b27c-516e64b1c744' AND c/uid/value = '${c_uid4b}'
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 1
${temporary_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_multiple_ehrs_and_compo_select_by_ids_tmp.json
${expected_file} Set Variable expected_multiple_ehrs_and_compo_select_by_ids.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}
${expected_result_file} Set Variable
... ${EXPECTED_JSON_DATA_SETS}/folder/expected_multiple_ehrs_and_compo_select_by_ids.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@ ${q} SELECT e/ehr_id/value, c/uid/value FROM EHR e CONTAINS FOLDER f CONTAINS
*** Test Cases ***
Over Multiple EHRs: ${q}
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}
${expected_result_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_contains_compo_over_multiple_ehrs.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@ Suite Teardown Admin Delete EHR For AQL
Folder Contains Composition: SELECT c/uid/value, f/name/value FROM FOLDER f CONTAINS COMPOSITION c
${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}
${expected_result_file} Set Variable
... ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_contains_compo_select_all.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}


*** Keywords ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ Precondition
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 File ${expected_res_tmp}
${data_replaced_vars} Replace Variables ${file_without_replaced_vars}
Create Binary File ${expected_file_with_replaced_vars}
... ${data_replaced_vars}
${expected_result_file} 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['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_file_with_replaced_vars}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json}
... 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}
Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ Find All: SELECT f1/uid/value, f1/name/value, f2/uid/value, f2/name/value FROM F
${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
${expected_result_file} 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}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ ${q} SELECT f/uid/value, f/name/value, f/archetype_node_id, f/items/id/value F
*** Test Cases ***
Find Items: ${q}
Set Test Variable ${query} ${q}
${temporary_file} Set Variable
... ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_find_items_tmp.json
Set AQL And Execute Ad Hoc Query ${query}
Length Should Be ${resp_body['rows']} 2
${expected_file} Set Variable expected_folder_find_items.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}
${expected_result_file} Set Variable ${EXPECTED_JSON_DATA_SETS}/folder/expected_folder_find_items.json
${exclude_paths} Create List root['meta'] root['q']
${diff} compare json-string with json-file
... ${resp_body_actual} ${temporary_file} exclude_paths=${exclude_paths}
${expected_json} Get File And Replace Dynamic Vars In File And Store As String
... test_data_file=${expected_result_file}
${diff} compare json-strings
... ${resp_body_actual} ${expected_json} exclude_paths=${exclude_paths}
... ignore_string_case=${TRUE}
Should Be Empty ${diff} msg=DIFF DETECTED!
[Teardown] Remove File ${temporary_file}



*** Keywords ***
Expand Down
9 changes: 9 additions & 0 deletions tests/robot/_resources/keywords/aql_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,12 @@ Set Debug Options In Dict
Set Test Variable ${query_plan} ${query_plan}
[Return] ${debug_headers}

Get File And Replace Dynamic Vars In File And Store As String
# Reads file identified by full path provided to test_data_file
# Replace all variables from the readed file content if it contains any
# Returns json with replaced variables
[Arguments] ${test_data_file}
${json_str} Get File ${test_data_file}
${json_str_replaced} Replace Variables ${json_str}
Log ${json_str_replaced}
[return] ${json_str_replaced}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"rows": [
[
"${c_uid4}::local.ehrbase.org::1"
"${c_uid4}::${system_id_with_tenant}::1"
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
],
"rows": [
[
"${c_uid1}::local.ehrbase.org::1"
"${c_uid1}::${system_id_with_tenant}::1"
],
[
"${c_uid2}::local.ehrbase.org::1"
"${c_uid2}::${system_id_with_tenant}::1"
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"rows": [
[
"${ehr_id1}",
"${c_uid4}::local.ehrbase.org::1"
"${c_uid4}::${system_id_with_tenant}::1"
],
[
"${ehr_id2}",
"${c_uid4b}::local.ehrbase.org::1"
"${c_uid4b}::${system_id_with_tenant}::1"
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"rows": [
[
"60e952ca-a5b2-4f24-8d37-59240fd37020::local.ehrbase.org::1",
"60e952ca-a5b2-4f24-8d37-59240fd37020::${system_id_with_tenant}::1",
"root1",
"openEHR-EHR-FOLDER.generic.v1"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"rows": [
[
"60e952ca-a5b2-4f24-8d37-59240fd37020::local.ehrbase.org::1"
"60e952ca-a5b2-4f24-8d37-59240fd37020::${system_id_with_tenant}::1"
]
]
}
Loading

0 comments on commit cf36c23

Please sign in to comment.