Class: Crucible::Tests::HistoryTest
- Defined in:
- lib/tests/suites/history_test.rb
Constant Summary
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
Instance Method Summary collapse
- #active_entries(entries) ⇒ Object
- #check_sort_order(entries) ⇒ Object
-
#deleted_entries(entries) ⇒ Object
Check sice with timezones?????.
- #description ⇒ Object
- #entry_ids_are_present(entries) ⇒ Object
- #id ⇒ Object
-
#initialize(client1, client2 = nil) ⇒ HistoryTest
constructor
A new instance of HistoryTest.
- #setup ⇒ Object
- #url?(v) ⇒ Boolean
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, #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_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
277 278 279 |
# File 'lib/tests/suites/history_test.rb', line 277 def active_entries(entries) entries - deleted_entries(entries) end |
#check_sort_order(entries) ⇒ Object
294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/tests/suites/history_test.rb', line 294 def check_sort_order(entries) relevant_entries = entries.select{|x|x.request.try(: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?????
270 271 272 273 274 275 |
# File 'lib/tests/suites/history_test.rb', line 270 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(: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
282 283 284 285 286 287 288 |
# File 'lib/tests/suites/history_test.rb', line 282 def entry_ids_are_present(entries) relevant_entries = entries.select{|x|x.request.try(:method)!='DELETE'} ids = relevant_entries.map(&:resource).map(&:xmlId).compact rescue assert(false, 'Unable to find IDs for resources returned by the bundle') # check that we have ids and self links 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 |
# File 'lib/tests/suites/history_test.rb', line 18 def setup @resources = Crucible::Generator::Resources.new @patient = @resources.minimal_patient @create_date = Time.now.utc @version = [] result = @client.create(@patient) assert_response_ok(result) @id = result.id @version << result.version @patient.xmlId = @id @patient.telecom << FHIR::ContactPoint.new(system: 'email', value: '[email protected]') update_result = @client.update(@patient, @id) assert_response_ok(update_result) @version << update_result.version del_result = @client.destroy(FHIR::Patient, @id) assert_response_code(del_result,204) @entry_count = @version.length # add one for deletion @version_count = @entry_count + 1 end |
#url?(v) ⇒ Boolean
290 291 292 |
# File 'lib/tests/suites/history_test.rb', line 290 def url?(v) v =~ /\A#{URI::regexp}\z/ end |