inferno_core 0.3.2 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/inferno/apps/web/controllers/test_sessions/create.rb +7 -3
- data/lib/inferno/apps/web/index.html.erb +6 -1
- data/lib/inferno/apps/web/router.rb +9 -2
- data/lib/inferno/apps/web/serializers/suite_option.rb +13 -0
- data/lib/inferno/apps/web/serializers/test_group.rb +6 -2
- data/lib/inferno/apps/web/serializers/test_session.rb +5 -3
- data/lib/inferno/apps/web/serializers/test_suite.rb +4 -1
- data/lib/inferno/config/boot/db.rb +1 -1
- data/lib/inferno/config/boot.rb +1 -1
- data/lib/inferno/db/migrations/007_add_suite_options.rb +5 -0
- data/lib/inferno/db/schema.rb +1 -0
- data/lib/inferno/dsl/configurable.rb +1 -1
- data/lib/inferno/dsl/fhir_client.rb +22 -10
- data/lib/inferno/dsl/fhir_validation.rb +35 -12
- data/lib/inferno/dsl/http_client.rb +47 -35
- data/lib/inferno/dsl/input_output_handling.rb +22 -2
- data/lib/inferno/dsl/runnable.rb +36 -10
- data/lib/inferno/dsl/suite_option.rb +40 -0
- data/lib/inferno/dsl/tcp_exception_handler.rb +11 -0
- data/lib/inferno/entities/test.rb +7 -3
- data/lib/inferno/entities/test_group.rb +4 -4
- data/lib/inferno/entities/test_session.rb +40 -1
- data/lib/inferno/entities/test_suite.rb +12 -14
- data/lib/inferno/public/bundle.js +15 -15
- data/lib/inferno/repositories/test_sessions.rb +24 -0
- data/lib/inferno/test_runner.rb +9 -3
- data/lib/inferno/version.rb +1 -1
- data/spec/support/factory_bot.rb +6 -0
- metadata +23 -7
- data/lib/inferno/public/bg-header-1920x170.png +0 -0
- data/lib/inferno/public/healthit.gov.logo.png +0 -0
data/lib/inferno/dsl/runnable.rb
CHANGED
@@ -9,6 +9,7 @@ module Inferno
|
|
9
9
|
# definition framework.
|
10
10
|
module Runnable
|
11
11
|
attr_accessor :parent
|
12
|
+
attr_reader :suite_option_requirements
|
12
13
|
|
13
14
|
include Inferno::Utils::MarkdownFormatter
|
14
15
|
|
@@ -48,7 +49,7 @@ module Inferno
|
|
48
49
|
VARIABLES_NOT_TO_COPY = [
|
49
50
|
:@id, # New runnable will have a different id
|
50
51
|
:@parent, # New runnable unlikely to have the same parent
|
51
|
-
:@
|
52
|
+
:@all_children, # New subclasses have to be made for each child
|
52
53
|
:@test_count, # Needs to be recalculated
|
53
54
|
:@config, # Needs to be set by calling .config, which does extra work
|
54
55
|
:@available_inputs, # Needs to be recalculated
|
@@ -63,13 +64,13 @@ module Inferno
|
|
63
64
|
|
64
65
|
subclass.config(config)
|
65
66
|
|
66
|
-
new_children =
|
67
|
+
new_children = all_children.map do |child|
|
67
68
|
Class.new(child).tap do |subclass_child|
|
68
69
|
subclass_child.parent = subclass
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
|
-
subclass.instance_variable_set(:@
|
73
|
+
subclass.instance_variable_set(:@all_children, new_children)
|
73
74
|
end
|
74
75
|
|
75
76
|
# @private
|
@@ -94,7 +95,7 @@ module Inferno
|
|
94
95
|
|
95
96
|
klass.parent = self
|
96
97
|
|
97
|
-
|
98
|
+
all_children << klass
|
98
99
|
|
99
100
|
configure_child_class(klass, hash_args)
|
100
101
|
|
@@ -172,7 +173,7 @@ module Inferno
|
|
172
173
|
|
173
174
|
klass.config(config)
|
174
175
|
|
175
|
-
klass.
|
176
|
+
klass.all_children.select!(&:required?) if hash_args.delete(:exclude_optional)
|
176
177
|
|
177
178
|
hash_args.each do |key, value|
|
178
179
|
if value.is_a? Array
|
@@ -182,7 +183,7 @@ module Inferno
|
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
185
|
-
klass.
|
186
|
+
klass.all_children.each do |child_class|
|
186
187
|
klass.configure_child_class(child_class, {})
|
187
188
|
child_class.add_self_to_repository
|
188
189
|
end
|
@@ -302,8 +303,8 @@ module Inferno
|
|
302
303
|
end
|
303
304
|
|
304
305
|
# @private
|
305
|
-
def
|
306
|
-
@
|
306
|
+
def all_children
|
307
|
+
@all_children ||= []
|
307
308
|
end
|
308
309
|
|
309
310
|
def validator_url(url = nil)
|
@@ -378,8 +379,12 @@ module Inferno
|
|
378
379
|
end
|
379
380
|
|
380
381
|
# @private
|
381
|
-
def test_count
|
382
|
-
@
|
382
|
+
def test_count(selected_suite_options = [])
|
383
|
+
@test_counts ||= {}
|
384
|
+
|
385
|
+
@test_counts[selected_suite_options] ||=
|
386
|
+
children(selected_suite_options)
|
387
|
+
&.reduce(0) { |sum, child| sum + child.test_count(selected_suite_options) } || 0
|
383
388
|
end
|
384
389
|
|
385
390
|
# @private
|
@@ -388,6 +393,27 @@ module Inferno
|
|
388
393
|
!parent.respond_to?(:run_as_group?) ||
|
389
394
|
(parent.user_runnable? && !parent.run_as_group?)
|
390
395
|
end
|
396
|
+
|
397
|
+
def required_suite_options(suite_option_requirements)
|
398
|
+
@suite_option_requirements =
|
399
|
+
suite_option_requirements.map do |key, value|
|
400
|
+
DSL::SuiteOption.new(id: key, value: value)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
def children(selected_suite_options = [])
|
405
|
+
return all_children if selected_suite_options.blank?
|
406
|
+
|
407
|
+
all_children.select do |child|
|
408
|
+
requirements = child.suite_option_requirements
|
409
|
+
|
410
|
+
if requirements.blank?
|
411
|
+
true
|
412
|
+
else
|
413
|
+
requirements.all? { |requirement| selected_suite_options.include? requirement }
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
391
417
|
end
|
392
418
|
end
|
393
419
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../entities/attributes'
|
2
|
+
|
3
|
+
module Inferno
|
4
|
+
module DSL
|
5
|
+
class SuiteOption
|
6
|
+
ATTRIBUTES = [
|
7
|
+
:id,
|
8
|
+
:title,
|
9
|
+
:description,
|
10
|
+
:list_options,
|
11
|
+
:value
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
include Entities::Attributes
|
15
|
+
|
16
|
+
def initialize(raw_params)
|
17
|
+
params = raw_params.deep_symbolize_keys
|
18
|
+
bad_params = params.keys - ATTRIBUTES
|
19
|
+
|
20
|
+
raise Exceptions::UnknownAttributeException.new(bad_params, self.class) if bad_params.present?
|
21
|
+
|
22
|
+
params
|
23
|
+
.compact
|
24
|
+
.each { |key, value| send("#{key}=", value) }
|
25
|
+
|
26
|
+
self.id = id.to_sym if id.is_a? String
|
27
|
+
end
|
28
|
+
|
29
|
+
def ==(other)
|
30
|
+
id == other.id && value == other.value
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_hash
|
34
|
+
self.class::ATTRIBUTES.each_with_object({}) do |attribute, hash|
|
35
|
+
hash[attribute] = send(attribute)
|
36
|
+
end.compact
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Inferno
|
2
|
+
module DSL
|
3
|
+
module TCPExceptionHandler
|
4
|
+
def tcp_exception_handler(&block)
|
5
|
+
block.call
|
6
|
+
rescue Faraday::ConnectionFailed, SocketError => e
|
7
|
+
e.message.include?('Failed to open TCP') ? raise(Exceptions::AssertionException, e.message) : raise(e)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -13,13 +13,14 @@ module Inferno
|
|
13
13
|
def_delegators 'self.class', :title, :id, :block, :inputs, :outputs
|
14
14
|
|
15
15
|
attr_accessor :result_message
|
16
|
-
attr_reader :test_session_id, :scratch
|
16
|
+
attr_reader :test_session_id, :scratch, :suite_options
|
17
17
|
|
18
18
|
# @private
|
19
19
|
def initialize(**params)
|
20
20
|
params[:inputs]&.each { |key, value| instance_variable_set("@#{key}", value) }
|
21
21
|
@scratch = params[:scratch]
|
22
22
|
@test_session_id = params[:test_session_id]
|
23
|
+
@suite_options = params[:suite_options].presence || {}
|
23
24
|
end
|
24
25
|
|
25
26
|
# @private
|
@@ -144,10 +145,12 @@ module Inferno
|
|
144
145
|
# Define outputs for this Test
|
145
146
|
#
|
146
147
|
# @param output_definitions [Symbol]
|
148
|
+
# @param _output_params [Hash] Unused parameter. Just makes method
|
149
|
+
# signature compatible with `Inferno::DSL::InputOutputHandling.output`
|
147
150
|
# @return [void]
|
148
151
|
# @example
|
149
152
|
# output :patient_id, :bearer_token
|
150
|
-
def output(*output_definitions)
|
153
|
+
def output(*output_definitions, **_output_params)
|
151
154
|
super
|
152
155
|
|
153
156
|
output_definitions.each do |output|
|
@@ -195,7 +198,8 @@ module Inferno
|
|
195
198
|
end
|
196
199
|
|
197
200
|
# @private
|
198
|
-
|
201
|
+
# Has an unused argument to match the method signature of Runnable#test_count
|
202
|
+
def test_count(_ = nil)
|
199
203
|
1
|
200
204
|
end
|
201
205
|
|
@@ -31,12 +31,12 @@ module Inferno
|
|
31
31
|
Inferno::Repositories::TestGroups.new
|
32
32
|
end
|
33
33
|
|
34
|
-
def groups
|
35
|
-
children.select { |child| child < Inferno::Entities::TestGroup }
|
34
|
+
def groups(options = nil)
|
35
|
+
children(options).select { |child| child < Inferno::Entities::TestGroup }
|
36
36
|
end
|
37
37
|
|
38
|
-
def tests
|
39
|
-
children.select { |child| child < Inferno::Entities::Test }
|
38
|
+
def tests(options = nil)
|
39
|
+
children(options).select { |child| child < Inferno::Entities::Test }
|
40
40
|
end
|
41
41
|
|
42
42
|
# Methods to configure Inferno::DSL::Runnable
|
@@ -19,13 +19,52 @@ module Inferno
|
|
19
19
|
# @!attribute results
|
20
20
|
# @return [Array<Inferno::Entities::TestResult>] the `TestResults`
|
21
21
|
# associated with this session
|
22
|
+
# @!attribute suite_options
|
23
|
+
# @return [Hash] the suite options associated with this session
|
22
24
|
class TestSession < Entity
|
23
|
-
ATTRIBUTES = [
|
25
|
+
ATTRIBUTES = [
|
26
|
+
:id,
|
27
|
+
:created_at,
|
28
|
+
:updated_at,
|
29
|
+
:test_suite_id,
|
30
|
+
:test_suite,
|
31
|
+
:test_runs,
|
32
|
+
:results,
|
33
|
+
:suite_options
|
34
|
+
].freeze
|
24
35
|
|
25
36
|
include Inferno::Entities::Attributes
|
26
37
|
|
27
38
|
def initialize(params)
|
28
39
|
super(params, ATTRIBUTES)
|
40
|
+
|
41
|
+
self.suite_options ||= []
|
42
|
+
|
43
|
+
test_suite.suite_options&.each do |option|
|
44
|
+
if suite_options.none? { |selected_option| selected_option.id == option.id }
|
45
|
+
suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_suite
|
51
|
+
@test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_hash
|
55
|
+
session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
|
56
|
+
hash[attribute] = send(attribute)
|
57
|
+
end
|
58
|
+
|
59
|
+
session_hash[:suite_options] = suite_options&.map(&:to_hash) || []
|
60
|
+
|
61
|
+
session_hash.compact
|
62
|
+
end
|
63
|
+
|
64
|
+
def suite_options_hash
|
65
|
+
(suite_options || []).each_with_object({}) do |option, hash|
|
66
|
+
hash[option.id] = option.value
|
67
|
+
end
|
29
68
|
end
|
30
69
|
end
|
31
70
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'test_group'
|
2
2
|
require_relative '../dsl/runnable'
|
3
|
+
require_relative '../dsl/suite_option'
|
3
4
|
require_relative '../repositories/test_groups'
|
4
5
|
require_relative '../repositories/test_suites'
|
5
6
|
|
@@ -22,7 +23,7 @@ module Inferno
|
|
22
23
|
return @default_group if @default_group
|
23
24
|
|
24
25
|
@default_group = Class.new(TestGroup)
|
25
|
-
|
26
|
+
all_children << @default_group
|
26
27
|
@default_group
|
27
28
|
end
|
28
29
|
|
@@ -30,8 +31,8 @@ module Inferno
|
|
30
31
|
Inferno::Repositories::TestSuites.new
|
31
32
|
end
|
32
33
|
|
33
|
-
def groups
|
34
|
-
children.select { |child| child < Inferno::Entities::TestGroup }
|
34
|
+
def groups(options = nil)
|
35
|
+
children(options).select { |child| child < Inferno::Entities::TestGroup }
|
35
36
|
end
|
36
37
|
|
37
38
|
# Methods to configure Inferno::DSL::Runnable
|
@@ -60,17 +61,6 @@ module Inferno
|
|
60
61
|
@version = version
|
61
62
|
end
|
62
63
|
|
63
|
-
def find_validator(validator_name)
|
64
|
-
validator = fhir_validators[validator_name]
|
65
|
-
|
66
|
-
return validator if validator
|
67
|
-
|
68
|
-
raise Exceptions::ValidatorNotFoundException, validator_name unless validator_name == :default
|
69
|
-
|
70
|
-
fhir_validators[:default] =
|
71
|
-
Inferno::DSL::FHIRValidation::Validator.new { |v| v.url default_validator_url }
|
72
|
-
end
|
73
|
-
|
74
64
|
def configuration_messages(new_messages = nil, force_recheck: false)
|
75
65
|
return @configuration_messages = new_messages unless new_messages.nil?
|
76
66
|
|
@@ -95,6 +85,14 @@ module Inferno
|
|
95
85
|
def presets
|
96
86
|
@presets ||= Repositories::Presets.new.presets_for_suite(id)
|
97
87
|
end
|
88
|
+
|
89
|
+
def suite_option(identifier, **input_params)
|
90
|
+
suite_options << DSL::SuiteOption.new(input_params.merge(id: identifier))
|
91
|
+
end
|
92
|
+
|
93
|
+
def suite_options
|
94
|
+
@suite_options ||= []
|
95
|
+
end
|
98
96
|
end
|
99
97
|
end
|
100
98
|
end
|