inferno_core 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9fb2c95aa9d590f9c05ceb25a236f0552ae2a94e91c49de3a116dbe970e62de
4
- data.tar.gz: e81873f6d4c4a4b620fa2831298ce089567d07df5e2ca93b70cec127c2f67fbf
3
+ metadata.gz: 470abbacaa895d2d3451f130734c0e34eec9303ec19858976f79b0456c0d619b
4
+ data.tar.gz: c60351312c3116c39260332b88675f2d8e2b0a3732be2dbf68c2a41c63cd62ab
5
5
  SHA512:
6
- metadata.gz: b5195ed44f0fb45fa7688e5dd3f4c74cc5012a689205cf39f27ab08a1ca25713cc4ce7a2c1351a281c311b38e38c28b72b5e09cf1771f88a220ebd6735ff87fd
7
- data.tar.gz: 96b4316208dd689aad2e1205ac29c15e452d0086f72bbe1dff8ee349eccf5c579165bf7610196dfdb1cfcd2e959ad8d536e2978d8a00c60e598551a619447a34
6
+ metadata.gz: 1ff98dd5180315c77a4627710a7bb9c5eaf82d87f81a173f849e24aadf6cad908feb71ac3d92b6a9ca14b38163cf9a821ce236c407e5eb688467e36295fd148e
7
+ data.tar.gz: 324efe61696b3e86b061adede76bd6c3a1d997f15e2c2e1225dc5edb3bc1f24f3ca7ec21b6363c060ed68eb1d66306baa247d34df8cb465a82c7d70b239a1bec
@@ -2,6 +2,10 @@ Inferno::Application.boot(:suites) do
2
2
  init do
3
3
  use :logging
4
4
 
5
+ require 'inferno/entities/test'
6
+ require 'inferno/entities/test_group'
7
+ require 'inferno/entities/test_suite'
8
+
5
9
  files_to_load = Dir.glob(File.join(Dir.pwd, 'lib', '*.rb'))
6
10
 
7
11
  if ENV['LOAD_DEV_SUITES'].present?
@@ -12,6 +12,7 @@ module Inferno
12
12
  # @param test a value whose truthiness will determine whether the
13
13
  # assertion passes or fails
14
14
  # @param message [String] failure message
15
+ # @return [void]
15
16
  def assert(test, message = '')
16
17
  raise Exceptions::AssertionException, message unless test
17
18
  end
@@ -26,6 +27,7 @@ module Inferno
26
27
  # @param status [Integer, Array<Integer>] a single integer or an array of
27
28
  # integer status codes
28
29
  # @param response [Hash]
30
+ # @return [void]
29
31
  def assert_response_status(status, response: self.response)
30
32
  assert Array.wrap(status).include?(response[:status]), bad_response_status_message(status, response[:status])
31
33
  end
@@ -44,6 +46,7 @@ module Inferno
44
46
  # assert_resource_type(:capability_statement)
45
47
  # assert_resource_type('CapabilityStatement')
46
48
  # assert_resource_type(FHIR::CapabilityStatement)
49
+ # @return [void]
47
50
  def assert_resource_type(resource_type, resource: self.resource)
48
51
  resource_type_name = normalize_resource_type(resource_type)
49
52
 
@@ -61,8 +64,10 @@ module Inferno
61
64
  # @param resource [FHIR::Model]
62
65
  # @param profile_url [String] url of the profile to validate against,
63
66
  # defaults to validating against the base FHIR resource
64
- def assert_valid_resource(resource: self.resource, profile_url: nil)
65
- assert resource_is_valid?(resource:, profile_url:),
67
+ # @param validator [Symbol] the name of the validator to use
68
+ # @return [void]
69
+ def assert_valid_resource(resource: self.resource, profile_url: nil, validator: :default)
70
+ assert resource_is_valid?(resource:, profile_url:, validator:),
66
71
  invalid_resource_message(profile_url)
67
72
  end
68
73
 
@@ -93,6 +98,7 @@ module Inferno
93
98
  # 'Condition': nil
94
99
  # }
95
100
  # )
101
+ # @return [void]
96
102
  def assert_valid_bundle_entries(bundle: resource, resource_types: {})
97
103
  assert_resource_type('Bundle', resource: bundle)
98
104
 
@@ -148,6 +154,7 @@ module Inferno
148
154
  #
149
155
  # @param maybe_json_string [String]
150
156
  # @param message [String] extra failure message
157
+ # @return [void]
151
158
  def assert_valid_json(maybe_json_string, message = '')
152
159
  assert JSON.parse(maybe_json_string)
153
160
  rescue JSON::ParserError
@@ -158,6 +165,7 @@ module Inferno
158
165
  #
159
166
  # @param uri [String]
160
167
  # @param message [String] custom failure message
168
+ # @return [void]
161
169
  def assert_valid_http_uri(uri, message = '')
162
170
  error_message = message.presence || "\"#{uri}\" is not a valid URI"
163
171
  assert uri =~ /\A#{URI::DEFAULT_PARSER.make_regexp(['http', 'https'])}\z/, error_message
@@ -167,6 +175,7 @@ module Inferno
167
175
  #
168
176
  # @param type [String]
169
177
  # @param request [Inferno::Entities::Request]
178
+ # @return [void]
170
179
  def assert_response_content_type(type, request: self.request)
171
180
  header = request.response_header('Content-Type')
172
181
  assert header.present?, no_content_type_message
@@ -6,6 +6,7 @@ module Inferno
6
6
  # configuration provides a way to modify test behavior at boot time.
7
7
  #
8
8
  # The main features enabled by configuration are:
9
+ #
9
10
  # - Modifying the properties of a runnable's inputs. This could include
10
11
  # locking a particular input, making a particular input optional/required,
11
12
  # or changing an input's value.
@@ -81,6 +82,7 @@ module Inferno
81
82
  # will be applied to the runnable and all of its children.
82
83
  #
83
84
  # @param new_configuration [Hash]
85
+ # @return [Inferno::DSL::Configurable::Configuration]
84
86
  def config(new_configuration = {})
85
87
  @config ||= Configuration.new
86
88
 
@@ -243,6 +243,7 @@ module Inferno
243
243
  # @param block a block to configure the client
244
244
  # @see Inferno::FHIRClientBuilder Documentation for the client
245
245
  # configuration DSL
246
+ # @return [void]
246
247
  def fhir_client(name = :default, &block)
247
248
  fhir_client_definitions[name] = block
248
249
  end
@@ -99,7 +99,8 @@ module Inferno
99
99
  .select { |message| message.is_a? Hash }
100
100
  end
101
101
 
102
- # Filter out unwanted validation messages
102
+ # Filter out unwanted validation messages. Any messages for which the
103
+ # block evalutates to a truthy value will be excluded.
103
104
  #
104
105
  # @example
105
106
  # validator do
@@ -198,6 +198,7 @@ module Inferno
198
198
  # @param block a block to configure the client
199
199
  # @see Inferno::HTTPClientBuilder Documentation for the client
200
200
  # configuration DSL
201
+ # @return [void]
201
202
  def http_client(name = :default, &block)
202
203
  http_client_definitions[name] = block
203
204
  end
@@ -47,7 +47,7 @@ module Inferno
47
47
  # @param identifier [Symbol] identifier for the output
48
48
  # @param other_identifiers [Symbol] array of symbols if specifying multiple outputs
49
49
  # @param output_definition [Hash] options for output
50
- # @option output_definition [String] :type text | textarea | oauth_credentials
50
+ # @option output_definition [String] :type text, textarea, or oauth_credentials
51
51
  # @return [void]
52
52
  # @example
53
53
  # output :patient_id, :condition_id, :observation_id
@@ -89,6 +89,7 @@ module Inferno
89
89
  # Specify the named requests made by a test
90
90
  #
91
91
  # @param identifiers [Symbol] one or more request identifiers
92
+ # @return [void]
92
93
  def makes_request(*identifiers)
93
94
  named_requests_made.concat(identifiers).uniq!
94
95
  identifiers.each do |identifier|
@@ -99,6 +100,7 @@ module Inferno
99
100
  # Specify the name for a request received by a test
100
101
  #
101
102
  # @param identifier [Symbol]
103
+ # @return [void]
102
104
  def receives_request(identifier)
103
105
  config.add_request(identifier)
104
106
  @incoming_request_name = identifier
@@ -112,6 +114,7 @@ module Inferno
112
114
  # Specify the named requests used by a test
113
115
  #
114
116
  # @param identifiers [Symbol] one or more request identifiers
117
+ # @return [void]
115
118
  def uses_request(*identifiers)
116
119
  named_requests_used.concat(identifiers).uniq!
117
120
  identifiers.each do |identifier|
@@ -5,6 +5,7 @@ module Inferno
5
5
  # Halt execution of the current test and mark it as passed.
6
6
  #
7
7
  # @param message [String]
8
+ # @return [void]
8
9
  def pass(message = '')
9
10
  raise Exceptions::PassException, message
10
11
  end
@@ -14,6 +15,7 @@ module Inferno
14
15
  #
15
16
  # @param test [Boolean]
16
17
  # @param message [String]
18
+ # @return [void]
17
19
  def pass_if(test, message = '')
18
20
  raise Exceptions::PassException, message if test
19
21
  end
@@ -21,6 +23,7 @@ module Inferno
21
23
  # Halt execution of the current test and mark it as skipped.
22
24
  #
23
25
  # @param message [String]
26
+ # @return [void]
24
27
  def skip(message = '')
25
28
  raise Exceptions::SkipException, message
26
29
  end
@@ -30,6 +33,7 @@ module Inferno
30
33
  #
31
34
  # @param test [Boolean]
32
35
  # @param message [String]
36
+ # @return [void]
33
37
  def skip_if(test, message = '')
34
38
  raise Exceptions::SkipException, message if test
35
39
  end
@@ -37,6 +41,7 @@ module Inferno
37
41
  # Halt execution of the current test and mark it as omitted.
38
42
  #
39
43
  # @param message [String]
44
+ # @return [void]
40
45
  def omit(message = '')
41
46
  raise Exceptions::OmitException, message
42
47
  end
@@ -46,6 +51,7 @@ module Inferno
46
51
  #
47
52
  # @param test [Boolean]
48
53
  # @param message [String]
54
+ # @return [void]
49
55
  def omit_if(test, message = '')
50
56
  raise Exceptions::OmitException, message if test
51
57
  end
@@ -75,6 +81,7 @@ module Inferno
75
81
  # @param message [String]
76
82
  # @param timeout [Integer] Number of seconds to wait for an incoming
77
83
  # request
84
+ # @return [void]
78
85
  def wait(identifier:, message: '', timeout: 300)
79
86
  identifier(identifier)
80
87
  wait_timeout(timeout)
@@ -268,7 +268,6 @@ module Inferno
268
268
  #
269
269
  # @param optional [Boolean]
270
270
  # @return [void]
271
- #
272
271
  def optional(optional = true) # rubocop:disable Style/OptionalBooleanParameter
273
272
  @optional = optional
274
273
  end
@@ -347,6 +346,7 @@ module Inferno
347
346
  # route. The block has access to the `request` method which returns a
348
347
  # {Inferno::Entities::Request} object with the information for the
349
348
  # incoming request.
349
+ # @return [void]
350
350
  def resume_test_route(method, path, &block)
351
351
  route_class = Class.new(ResumeTestRoute) do |klass|
352
352
  klass.singleton_class.instance_variable_set(:@test_run_identifier_block, block)
@@ -368,6 +368,7 @@ module Inferno
368
368
  # compatible object (e.g. a `Proc` object, a [Sinatra
369
369
  # app](http://sinatrarb.com/)) as described in the [Hanami Router
370
370
  # documentation.](https://github.com/hanami/router/tree/f41001d4c3ee9e2d2c7bb142f74b43f8e1d3a265#mount-rack-applications)
371
+ # @return [void]
371
372
  def route(method, path, handler)
372
373
  Inferno.routes << { method:, path:, handler:, suite: }
373
374
  end
@@ -414,6 +415,7 @@ module Inferno
414
415
  # group from: :ig_v2_group do
415
416
  # required_suite_options ig_version: 'ig_v2'
416
417
  # end
418
+ # @return [void]
417
419
  def required_suite_options(suite_option_requirements)
418
420
  @suite_option_requirements =
419
421
  suite_option_requirements.map do |key, value|
@@ -436,6 +438,7 @@ module Inferno
436
438
  end
437
439
  end
438
440
 
441
+ # @private
439
442
  def inspect
440
443
  non_dynamic_ancestor = ancestors.find { |ancestor| !ancestor.to_s.start_with? '#' }
441
444
  "#<#{non_dynamic_ancestor}".tap do |inspect_string|
@@ -58,29 +58,29 @@ module Inferno
58
58
  # Find a response header
59
59
  #
60
60
  # @param name [String] the header name
61
- # @return [Inferno::Entities::RequestHeader, nil]
61
+ # @return [Inferno::Entities::Header, nil]
62
62
  def response_header(name)
63
63
  response_headers.find { |header| header.name.casecmp(name).zero? }
64
64
  end
65
65
 
66
66
  # Find a request header
67
67
  #
68
- # @param name [String] the header name
69
- # @return [Inferno::Entities::RequestHeader, nil]
68
+ # @param name [String] the header name.
69
+ # @return [Inferno::Entities::Header, nil]
70
70
  def request_header(name)
71
71
  request_headers.find { |header| header.name.casecmp(name).zero? }
72
72
  end
73
73
 
74
74
  # All of the request headers
75
75
  #
76
- # @return [Array<Inferno::Entities::RequestHeader>]
76
+ # @return [Array<Inferno::Entities::Header>]
77
77
  def request_headers
78
78
  headers.select(&:request?)
79
79
  end
80
80
 
81
81
  # All of the response headers
82
82
  #
83
- # @return [Array<Inferno::Entities::RequestHeader>]
83
+ # @return [Array<Inferno::Entities::Header>]
84
84
  def response_headers
85
85
  headers.select(&:response?)
86
86
  end
@@ -131,7 +131,7 @@ module Inferno
131
131
 
132
132
  # Return the FHIR resource from the response body.
133
133
  #
134
- # @return [FHIR::Model]
134
+ # @return [FHIR::Model, nil]
135
135
  def resource
136
136
  FHIR.from_contents(response_body)
137
137
  end
@@ -28,6 +28,11 @@ module Inferno
28
28
  @messages ||= []
29
29
  end
30
30
 
31
+ # Add a message to the result.
32
+ #
33
+ # @param type [String] error, warning, or info
34
+ # @param message [String]
35
+ # @return [void]
31
36
  def add_message(type, message)
32
37
  messages << { type: type.to_s, message: format_markdown(message) }
33
38
  end
@@ -40,7 +45,6 @@ module Inferno
40
45
  # @example
41
46
  # output(patient_id: '5', bearer_token: 'ABC')
42
47
  def output(outputs)
43
- # TODO: update to track outputs that need to be updated
44
48
  outputs.each do |key, value|
45
49
  send("#{key}=", value)
46
50
  outputs_to_persist[key] = value
@@ -158,6 +162,7 @@ module Inferno
158
162
  end
159
163
  end
160
164
 
165
+ # @private
161
166
  def repository
162
167
  Inferno::Repositories::Tests.new
163
168
  end
@@ -28,6 +28,7 @@ module Inferno
28
28
  end
29
29
 
30
30
  class << self
31
+ # @private
31
32
  def repository
32
33
  Inferno::Repositories::TestGroups.new
33
34
  end
@@ -53,12 +54,14 @@ module Inferno
53
54
  # Methods to configure Inferno::DSL::Runnable
54
55
 
55
56
  # Add a child group
57
+ # @return [void]
56
58
  def group(...)
57
59
  child_metadata(group_metadata)
58
60
  define_child(...)
59
61
  end
60
62
 
61
63
  # Add a test
64
+ # @return [void]
62
65
  def test(...)
63
66
  child_metadata(test_metadata)
64
67
  define_child(...)
@@ -108,6 +111,7 @@ module Inferno
108
111
  # UI, and this group must be run as a group.
109
112
  #
110
113
  # @param value [Boolean]
114
+ # @return [void]
111
115
  def run_as_group(value = true) # rubocop:disable Style/OptionalBooleanParameter
112
116
  @run_as_group = value
113
117
  end
@@ -28,6 +28,7 @@ module Inferno
28
28
  @default_group
29
29
  end
30
30
 
31
+ # @private
31
32
  def repository
32
33
  Inferno::Repositories::TestSuites.new
33
34
  end
@@ -44,6 +45,7 @@ module Inferno
44
45
  # Methods to configure Inferno::DSL::Runnable
45
46
 
46
47
  # Add a child group
48
+ # @return [void]
47
49
  def group(...)
48
50
  child_metadata(group_metadata)
49
51
  define_child(...)
@@ -93,6 +95,7 @@ module Inferno
93
95
  # @yieldreturn [Array<Hash>] An array of message hashes containing the
94
96
  # keys `:type` and `:message`. Type options are `info`, `warning`, and
95
97
  # `error`.
98
+ # @return [void]
96
99
  def check_configuration(&block)
97
100
  @check_configuration_block = block
98
101
  end
@@ -134,6 +137,7 @@ module Inferno
134
137
  # group from: :ig_v2_group do
135
138
  # required_suite_options ig_version: 'ig_v2'
136
139
  # end
140
+ # @return [void]
137
141
  def suite_option(identifier, **option_params)
138
142
  suite_options << DSL::SuiteOption.new(option_params.merge(id: identifier))
139
143
  end
@@ -27,7 +27,7 @@ end
27
27
  module InfernoJson
28
28
  def from_json(json)
29
29
  resource = super(json)
30
- resource.source_text = json
30
+ resource&.source_text = json
31
31
  resource
32
32
  end
33
33
  end
@@ -37,7 +37,7 @@ end
37
37
  module InfernoXml
38
38
  def from_xml(xml)
39
39
  resource = super(xml)
40
- resource.source_text = xml
40
+ resource&.source_text = xml
41
41
  resource
42
42
  end
43
43
  end