Class: Crucible::Tests::BaseSuite
Direct Known Subclasses
ArgonautProviderConnectathonTest, ConnectathonAttachmentTrackTest, ConnectathonAuditEventAndProvenanceTrackTest, ConnectathonCarePlanTrackTest, ConnectathonFetchPatientRecordTest, ConnectathonFinancialTrackTest, ConnectathonGenomicsTrackTest, ConnectathonLabOrderTrackTest, ConnectathonPatchTrackTest, ConnectathonPatientTrackTest, ConnectathonProfileValidationTrackTest, ConnectathonSchedulingTrackTest, ConnectathonTerminologyTrackTest, DataAccessFrameworkProfilesTest, FormatTest, HistoryTest, ReadTest, ResourceTest, RobustSearchTest, SearchTest, SprinklerSearchTest, TransactionAndBatchTest
Constant Summary
collapse
- EXCLUDED_RESOURCES =
['DomainResource', 'Resource', 'Parameters', 'OperationOutcome']
Constants inherited
from BaseTest
Crucible::Tests::BaseTest::BASE_SPEC_LINK, Crucible::Tests::BaseTest::JSON_FIELDS, Crucible::Tests::BaseTest::METADATA_FIELDS, Crucible::Tests::BaseTest::REST_SPEC_LINK, Crucible::Tests::BaseTest::STATUS
Instance Attribute Summary
Attributes inherited from BaseTest
#category, #tags, #tests_subset, #warnings
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseTest
#author, #description, #details, #execute, #execute_test_method, #execute_test_methods, #id, #ignore_client_exception, #initialize, #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
Class Method Details
.fhir_resources ⇒ Object
31
32
33
|
# File 'lib/tests/suites/base_suite.rb', line 31
def self.fhir_resources
FHIR::RESOURCES.select {|r| !EXCLUDED_RESOURCES.include?(r)}.map {|r| "FHIR::#{r}".constantize}
end
|
.test(key, desc, &block) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/tests/suites/base_suite.rb', line 65
def self.test(key, desc, &block)
test_method = "#{key} #{desc} test".downcase.tr(' ', '_').to_sym
contents = block
wrapped = -> () do
@warnings, @links, @requires, @validates = [],[],[],[]
description = nil
if respond_to? :supplement_test_description
description = supplement_test_description(desc)
else
description = desc
end
result = TestResult.new(key, description, STATUS[:pass], '','')
begin
t = instance_eval &block
result.update(t.status, t.message, t.data) if !t.nil? && t.is_a?(Crucible::Tests::TestResult)
rescue AssertionException => e
result.update(STATUS[:fail], e.message, e.data)
rescue SkipException => e
result.update(STATUS[:skip], "Skipped: #{test_method}", '')
rescue ClientException => e
result.update(STATUS[:fail], e.message, '')
rescue => e
result.update(STATUS[:error], "Fatal Error: #{e.message}", e.backtrace.join("\n"))
end
result.update(STATUS[:skip], "Skipped because setup failed.", "-") if @setup_failed
result.warnings = @warnings unless @warnings.empty?
result.requires = @requires unless @requires.empty?
result.validates = @validates unless @validates.empty?
result.links = @links unless @links.empty?
result.id = key
result.code = contents.source
result.id = "#{result.id}_#{result_id_suffix}" if respond_to? :result_id_suffix
result
end
define_method test_method, wrapped
end
|
Instance Method Details
#build_messages(operation_outcome) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/tests/suites/base_suite.rb', line 23
def build_messages(operation_outcome)
messages = []
if !operation_outcome.nil? and !operation_outcome.issue.nil?
operation_outcome.issue.each {|issue| messages << "#{issue.severity}: #{issue.code}: #{issue.details.try(:text) || issue.diagnostics}" }
end
messages
end
|
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/tests/suites/base_suite.rb', line 47
def collect_metadata(methods_only=false)
@metadata_only = true
if @resource_class
result = execute(@resource_class)
else
result = execute
end
result = result.values.first if methods_only
@metadata_only = false
result
end
|
#links(url) ⇒ Object
43
44
45
|
# File 'lib/tests/suites/base_suite.rb', line 43
def links(url)
@links << url
end
|
59
60
61
62
63
|
# File 'lib/tests/suites/base_suite.rb', line 59
def metadata(&block)
yield
skip if @setup_failed
skip if @metadata_only
end
|
#parse_operation_outcome(body) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/tests/suites/base_suite.rb', line 11
def parse_operation_outcome(body)
outcome = nil
begin
outcome = FHIR.from_contents(body)
outcome = nil if outcome.class!=FHIR::OperationOutcome
rescue
outcome = nil
end
outcome
end
|
#requires(hash) ⇒ Object
35
36
37
|
# File 'lib/tests/suites/base_suite.rb', line 35
def requires(hash)
@requires << hash
end
|
#resource_category(resource) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/tests/suites/base_suite.rb', line 103
def resource_category(resource)
unless @resource_category
@categories_by_resource = {}
fhir_structure = Crucible::FHIRStructure.get
categories = fhir_structure['children'].select {|n| n['name'] == 'RESOURCES'}.first['children']
pull_children = lambda {|n, chain| n['children'].nil? ? n['name'] : n['children'].map {|child| chain.call(child, chain)}}
categories.each do |category|
pull_children.call(category, pull_children).flatten.each do |resource_name|
@categories_by_resource[resource_name] = category['name']
end
end
end
@categories_by_resource[resource.underscore.humanize.downcase] || 'Uncategorized'
end
|
#title ⇒ Object
7
8
9
|
# File 'lib/tests/suites/base_suite.rb', line 7
def title
self.class.name.demodulize
end
|
#validates(hash) ⇒ Object
39
40
41
|
# File 'lib/tests/suites/base_suite.rb', line 39
def validates(hash)
@validates << hash
end
|