Skip to content

Commit

Permalink
Add comparators for multipleAnd tests
Browse files Browse the repository at this point in the history
Ref: #106
  • Loading branch information
projkov committed Sep 19, 2024
1 parent 55ea6ee commit b4528de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def multiple_and_expectation

def values
fixed_diagnostic_result_values = %w[251739003 24701-5]
fixed_date_value = %w[ge1950-01-01 le2050-01-01]
fixed_date_value = %w[1950-01-01 2050-01-01]
# NOTE: In the current step we don't need to check the correct content of the response.
# We should care about the correct structure of the request. In this current case we use dates just
# to check that server can make a response for the request.
Expand Down
17 changes: 12 additions & 5 deletions lib/au_core_test_kit/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ def perform_multiple_and_search_test
end

def modify_value_by_multiple_type(values, multiple_type)
return [values.join(',')] if multiple_type == 'or'

Array.wrap(values)
multiple_type == 'or' ? [values.join(',')] : Array.wrap(values)
end

def perform_multiple_search_test(multiple_type)
Expand All @@ -433,10 +431,19 @@ def perform_multiple_search_test(multiple_type)
else
param_name = search_param_names[0]
default_search_values = default_search_values_clean(param_name.to_sym)
req_comparators = required_comparators(param_name)

if default_search_values.length > 1
search_params = { param_name => modify_value_by_multiple_type(default_search_values, multiple_type) }
search_and_check_response(search_params)
if req_comparators.length.positive?
combo_values_to_search = [["ge", "le"], ["gt", "lt"]].map { |combo_comp| [date_comparator_value(combo_comp[0], default_search_values[0]), date_comparator_value(combo_comp[1], default_search_values[1])] }
combo_values_to_search.each do |combo_values|
search_params = { param_name => modify_value_by_multiple_type(combo_values, multiple_type) }
search_and_check_response(search_params)
end
else
search_params = { param_name => modify_value_by_multiple_type(default_search_values, multiple_type) }
search_and_check_response(search_params)
end
else
resources_arr = all_search_params.map { |patient_id, _params_list| scratch_resources_for_patient(patient_id) }.flatten
existing_values = extract_existing_values_safety(resources_arr, param_name)
Expand Down

0 comments on commit b4528de

Please sign in to comment.