Class: Crucible::Tests::HistoryTest
Constant Summary
Constants inherited
from BaseSuite
BaseSuite::EXCLUDED_RESOURCES
Constants inherited
from BaseTest
BaseTest::BASE_SPEC_LINK, BaseTest::JSON_FIELDS, BaseTest::METADATA_FIELDS, BaseTest::REST_SPEC_LINK, BaseTest::STATUS
Instance Attribute Summary
Attributes inherited from BaseTest
#category, #tags, #tests_subset, #warnings
Instance Method Summary
collapse
Methods inherited from BaseSuite
#build_messages, #collect_metadata, fhir_resources, #links, #metadata, #parse_operation_outcome, #requires, #resource_category, test, #title, #validates
Methods inherited from BaseTest
#author, #details, #execute, #execute_test_method, #execute_test_methods, #ignore_client_exception, #multiserver, #requires_authorization, #tests, #warning
Methods included from Assertions
#assert, #assert_bundle_entry_count, #assert_bundle_response, #assert_bundle_transactions_okay, #assert_equal, #assert_etag_present, #assert_last_modified_present, #assert_minimum, #assert_navigation_links, #assert_operator, #assert_resource_content_type, #assert_resource_type, #assert_response_bad, #assert_response_code, #assert_response_conflict, #assert_response_created, #assert_response_gone, #assert_response_not_found, #assert_response_ok, #assert_valid_content_location_present, #assert_valid_profile, #assert_valid_resource_content_type_present, #assertion_negated, #skip
Constructor Details
#initialize(client1, client2 = nil) ⇒ HistoryTest
Returns a new instance of HistoryTest.
13
14
15
16
|
# File 'lib/tests/suites/history_test.rb', line 13
def initialize(client1, client2=nil)
super(client1, client2)
@category = {id: 'core_functionality', title: 'Core Functionality'}
end
|
Instance Method Details
#active_entries(entries) ⇒ Object
281
282
283
|
# File 'lib/tests/suites/history_test.rb', line 281
def active_entries(entries)
entries - deleted_entries(entries)
end
|
#check_sort_order(entries) ⇒ Object
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
# File 'lib/tests/suites/history_test.rb', line 298
def check_sort_order(entries)
relevant_entries = entries.select{|x|x.request.try(:local_method)!='DELETE'}
relevant_entries.map!(&:resource).map!(&:meta).compact rescue assert(false, 'Unable to find meta for resources returned by the bundle')
relevant_entries.each_cons(2) do |left, right|
if !left.versionId.nil? && !right.versionId.nil?
assert (left.versionId > right.versionId), 'Result contains entries in the wrong order.'
elsif !left.lastUpdated.nil? && !right.lastUpdated.nil?
assert (left.lastUpdated >= right.lastUpdated), 'Result contains entries in the wrong order.'
else
raise AssertionException.new 'Unable to determine if entries are in the correct order -- no meta.versionId or meta.lastUpdated'
end
end
end
|
#deleted_entries(entries) ⇒ Object
Check sice with timezones?????
274
275
276
277
278
279
|
# File 'lib/tests/suites/history_test.rb', line 274
def deleted_entries(entries)
entries.select do |entry|
assert !entry.request.nil?, "history bundle entries do not have request elements, deleted entries cannot be distinguished"
entry.request.try(:local_method) == "DELETE"
end
end
|
#description ⇒ Object
9
10
11
|
# File 'lib/tests/suites/history_test.rb', line 9
def description
'Initial Sprinkler tests (HI01,HI02,HI03,HI04,HI05,HI06,HI07,HI08,HI09,HI10,HI11) for testing resource history requests.'
end
|
#entry_ids_are_present(entries) ⇒ Object
286
287
288
289
290
291
292
|
# File 'lib/tests/suites/history_test.rb', line 286
def entry_ids_are_present(entries)
relevant_entries = entries.select{|x|x.request.try(:local_method)!='DELETE'}
ids = relevant_entries.map(&:resource).map(&:id).compact rescue assert(false, 'Unable to find IDs for resources returned by the bundle')
assert_equal relevant_entries.length, ids.size, 'All PUT and POST entries must have an ID'
end
|
#id ⇒ Object
5
6
7
|
# File 'lib/tests/suites/history_test.rb', line 5
def id
'History001'
end
|
#setup ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/tests/suites/history_test.rb', line 18
def setup
begin
@resources = Crucible::Generator::Resources.new
response = @client.create(@resources.minimal_patient)
assert_response_ok(response)
@patient = response.resource
@patient_created = true
@create_date = Time.now.utc
@version = []
@version << @client.reply.version
@patient.telecom ||= []
@patient.telecom << FHIR::ContactPoint.new.from_hash(system: 'email', value: '[email protected]')
@patient.update
@version << @client.reply.version
@patient.destroy
assert_response_code(@client.reply,204)
@entry_count = @version.length
@version_count = @entry_count + 1
@patient_setup = true
rescue Exception => e
@patient_setup = false
@create_date = Time.now.utc
end
end
|
#teardown ⇒ Object
48
49
50
|
# File 'lib/tests/suites/history_test.rb', line 48
def teardown
ignore_client_exception { @patient.destroy if @patient_created }
end
|
#url?(v) ⇒ Boolean
294
295
296
|
# File 'lib/tests/suites/history_test.rb', line 294
def url?(v)
v =~ /\A#{URI::regexp}\z/
end
|