class Crucible::Tests::FormatTest
Public Class Methods
new(client1, client2=nil)
click to toggle source
Calls superclass method
Crucible::Tests::BaseTest::new
# File lib/tests/suites/format_test.rb, line 19 def initialize(client1, client2=nil) super(client1, client2) @category = {id: 'core_functionality', title: 'Core Functionality'} end
Public Instance Methods
description()
click to toggle source
# File lib/tests/suites/format_test.rb, line 15 def description 'Initial Sprinkler tests (CT01, CT02, CT03, CT04) for testing resource format requests.' end
id()
click to toggle source
# File lib/tests/suites/format_test.rb, line 11 def id 'Format001' end
setup()
click to toggle source
Create a patient and store its details for format requests
# File lib/tests/suites/format_test.rb, line 25 def setup @resources = Crucible::Generator::Resources.new @resource = @resources.minimal_patient @create_failed = false create_reply = @client.create(@resource) begin assert_response_created create_reply result = create_reply.resource rescue AssertionException @create_failed = true end if @create_failed # If create fails, pick one from the Patient Bundle begin bundle_reply = request_bundle(FHIR::Patient, @xml_format) assert_response_ok bundle_reply bundle_patient = bundle_reply.resource.entry.first.resource @id = bundle_patient.id @create_failed = false rescue Exception @create_failed = true end else @id = create_reply.id end assert(!@create_failed, 'Unable to create or read a patient.') end
teardown()
click to toggle source
Delete the reference patient if we created it
# File lib/tests/suites/format_test.rb, line 58 def teardown @client.destroy(FHIR::Patient, @id) unless @create_failed end
Private Instance Methods
compare_entries(entry1, entry2)
click to toggle source
Compare two requested entries
# File lib/tests/suites/format_test.rb, line 286 def compare_entries(entry1, entry2) compare_response(entry1) && compare_response(entry2) && entry1.resource.equals?(entry2.resource,['id']) end
compare_response(entry)
click to toggle source
Compare requested resource with created resource
# File lib/tests/suites/format_test.rb, line 276 def compare_response(entry) entry != nil && entry.resource != nil && entry.resource.equals?(@resource,['id']) end
compare_response_format(entry, requested_format)
click to toggle source
Compare response format with requested format
# File lib/tests/suites/format_test.rb, line 281 def compare_response_format(entry, requested_format) entry != nil && entry.response != nil && entry.response_format == requested_format end
request_bundle(resource_class, format, use_format_param=false)
click to toggle source
Unify Bundle requests and format specification
# File lib/tests/suites/format_test.rb, line 301 def request_bundle(resource_class, format, use_format_param=false) @client.use_format_param = use_format_param entry = @client.read_feed(resource_class, format) @client.use_format_param = false assert_response_ok entry, "Failed to retrieve Bundle: #{entry.request[:url]}" entry end
request_entry(resource_class, id, format, use_format_param=false)
click to toggle source
Unify resource requests and format specification
# File lib/tests/suites/format_test.rb, line 291 def request_entry(resource_class, id, format, use_format_param=false) @client.use_format_param = use_format_param entry = @client.read(resource_class, id, format) @client.use_format_param = false assert_response_ok entry, "Failed to retrieve resource: #{entry.request[:url]}" # entry.resource.id = id if !entry.resource.nil? entry end