Class: Crucible::Tests::FormatTest

Inherits:
BaseSuite show all
Defined in:
lib/tests/suites/format_test.rb

Constant Summary collapse

@@xml_format =
FHIR::Formats::ResourceFormat::RESOURCE_XML
@@json_format =
FHIR::Formats::ResourceFormat::RESOURCE_JSON
@@xml_format_params =
['xml', 'text/xml', 'application/xml', @@xml_format]
@@json_format_params =
['json', 'application/json', @@json_format]
@@alpha =
['A', 'B', 'C', 'D']

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) ⇒ FormatTest

Returns a new instance of FormatTest.



19
20
21
22
# 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

Instance Method Details

#descriptionObject



15
16
17
# File 'lib/tests/suites/format_test.rb', line 15

def description
  'Initial Sprinkler tests (CT01, CT02, CT03, CT04) for testing resource format requests.'
end

#idObject



11
12
13
# File 'lib/tests/suites/format_test.rb', line 11

def id
  'Format001'
end

#setupObject

Create a patient and store its details for format requests



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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

#teardownObject

Delete the reference patient if we created it



58
59
60
# File 'lib/tests/suites/format_test.rb', line 58

def teardown
  @client.destroy(FHIR::Patient, @id) unless @create_failed
end