Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Update search tests to use count if total not provided in bundle #177

Open
wants to merge 1 commit into
base: r4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/tests/suites/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,19 @@ def setup

replyB = @client.read_feed(@resource_class)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?
totalB = replyB.resource.total
totalB = replyB.resource&.entry&.count if totalB.nil?

# AuditEvent
if resource_class == get_resource(:AuditEvent)
count = (reply.resource.total-replyB.resource.total).abs
count = (total-totalB).abs
assert (count <= 1), 'Searching without criteria did not return all the results.'
else
assert !replyB.resource.nil?, 'Searching without criteria did not return any results.'
assert !reply.resource.nil?, 'Searching without criteria did not return any results.'
assert !replyB.resource.total.nil?, 'Search bundle returned does not report a total entry count.'
assert !reply.resource.total.nil?, 'Search bundle returned does not report a total entry count.'
assert_operator :greaterThan, totalB, 0, 'Searching without criteria did not return any results.'
assert_operator :greaterThan, total, 0, 'Searching without criteria did not return any results.'
assert_equal replyB.resource.total, reply.resource.total, 'Searching without criteria did not return all the results.'
end
end
Expand Down
35 changes: 30 additions & 5 deletions lib/tests/suites/sprinkler_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ def teardown
}
}
reply = @client.search(get_resource(:Patient), options)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?

assert_response_ok(reply)
assert_bundle_response(reply)
assert_equal expected, reply.resource.total, 'The server did not report the expected number of results.'
assert_equal expected, total, 'The server did not report the expected number of results.'
end

test "SE04#{action[0]}", 'Search patient resource on given name' do
Expand Down Expand Up @@ -226,9 +231,14 @@ def teardown
}
}
reply = @client.search(get_resource(:Patient), options)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?

assert_response_ok(reply)
assert_bundle_response(reply)
assert_equal expected, reply.resource.total, 'The server did not report the expected number of results.'
assert_equal expected, total, 'The server did not report the expected number of results.'
end

test "SE05.0#{action[0]}", 'Search condition by patient reference url (partial)' do
Expand Down Expand Up @@ -530,9 +540,14 @@ def teardown
}
}
reply = @client.search(get_resource(:Condition), options)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?

assert_response_ok(reply)
assert_bundle_response(reply)
assert reply.resource.total > 0, 'The server should have Conditions that _include=Condition:patient.'
assert_operator :greaterThan, total, 0, 'The server should have Conditions that _include=Condition:patient.'
has_patient = false
reply.resource.entry.each do |entry|
has_patient = true if (entry.resource && entry.resource.class == get_resource(:Patient))
Expand Down Expand Up @@ -561,9 +576,14 @@ def teardown
}
}
reply = @client.search(get_resource(:Patient), options)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?

assert_response_ok(reply)
assert_bundle_response(reply)
assert reply.resource.total > 0, 'The server should have Patients that are _revinclude=Condition:patient.'
assert_operator :greaterThan, total, 0, 'The server should have Patients that are _revinclude=Condition:patient.'
has_condition = false
reply.resource.entry.each do |entry|
has_condition = true if (entry.resource && entry.resource.class == get_resource(:Condition))
Expand Down Expand Up @@ -669,9 +689,14 @@ def teardown
}
}
reply = @client.search(get_resource(:Patient), options)

# bundle.total is optional
total = reply.resource.total
total = reply.resource&.entry&.count if total.nil?

assert_response_ok(reply)
assert_bundle_response(reply)
assert_equal expected, reply.resource.total, 'The server did not report the expected number of results.'
assert_equal expected, total, 'The server did not report the expected number of results.'
end

test "SE24#{action[0]}", 'Search with non-existing parameter' do
Expand Down