inferno_core 0.0.8 → 0.1.1
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_runs/create.rb +2 -1
- data/lib/inferno/apps/web/serializers/result.rb +1 -0
- data/lib/inferno/apps/web/serializers/test.rb +4 -0
- data/lib/inferno/apps/web/serializers/test_group.rb +4 -0
- data/lib/inferno/apps/web/serializers/test_suite.rb +3 -0
- data/lib/inferno/db/migrations/001_create_initial_structure.rb +54 -53
- data/lib/inferno/db/migrations/002_add_wait_support.rb +2 -2
- data/lib/inferno/db/migrations/003_update_session_data.rb +7 -7
- data/lib/inferno/db/migrations/004_add_request_results_table.rb +2 -2
- data/lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb +1 -1
- data/lib/inferno/db/migrations/006_remove_unused_tables.rb +38 -0
- data/lib/inferno/db/schema.rb +17 -43
- data/lib/inferno/dsl/configurable.rb +12 -5
- data/lib/inferno/dsl/fhir_client.rb +58 -6
- data/lib/inferno/dsl/fhir_client_builder.rb +16 -0
- data/lib/inferno/dsl/http_client.rb +62 -0
- data/lib/inferno/dsl/oauth_credentials.rb +119 -0
- data/lib/inferno/dsl/runnable.rb +87 -9
- data/lib/inferno/entities/has_runnable.rb +26 -0
- data/lib/inferno/entities/request.rb +7 -1
- data/lib/inferno/entities/result.rb +8 -4
- data/lib/inferno/entities/test_group.rb +4 -6
- data/lib/inferno/entities/test_run.rb +1 -18
- data/lib/inferno/entities/test_suite.rb +3 -4
- data/lib/inferno/entities.rb +1 -0
- data/lib/inferno/exceptions.rb +19 -0
- data/lib/inferno/ext/fhir_client.rb +13 -0
- data/lib/inferno/public/bundle.js +14 -14
- data/lib/inferno/repositories/session_data.rb +40 -6
- data/lib/inferno/result_summarizer.rb +40 -0
- data/lib/inferno/spec_support.rb +1 -1
- data/lib/inferno/test_runner.rb +13 -9
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/request.rb +1 -1
- data/spec/factories/result.rb +2 -2
- data/spec/fixtures/basic_test_group.rb +1 -0
- metadata +7 -2
@@ -4,22 +4,33 @@ module Inferno
|
|
4
4
|
def save(params)
|
5
5
|
name = params[:name].to_s.downcase
|
6
6
|
test_session_id = params[:test_session_id]
|
7
|
+
|
8
|
+
value = value_to_persist(params)
|
9
|
+
|
7
10
|
db
|
8
11
|
.insert_conflict(
|
9
12
|
target: :id,
|
10
|
-
update: { value:
|
13
|
+
update: { value: value }
|
11
14
|
).insert(
|
12
15
|
id: "#{test_session_id}_#{name}",
|
13
16
|
name: name,
|
14
|
-
value:
|
17
|
+
value: value,
|
15
18
|
test_session_id: test_session_id
|
16
19
|
)
|
17
20
|
end
|
18
21
|
|
19
|
-
def load(test_session_id:, name:)
|
20
|
-
|
21
|
-
.
|
22
|
-
|
22
|
+
def load(test_session_id:, name:, type: 'text')
|
23
|
+
raw_value =
|
24
|
+
self.class::Model
|
25
|
+
.find(test_session_id: test_session_id, name: name.to_s.downcase)
|
26
|
+
&.value
|
27
|
+
|
28
|
+
case type.to_s
|
29
|
+
when 'oauth_credentials'
|
30
|
+
DSL::OAuthCredentials.new(JSON.parse(raw_value))
|
31
|
+
else
|
32
|
+
raw_value
|
33
|
+
end
|
23
34
|
end
|
24
35
|
|
25
36
|
def get_all_from_session(test_session_id)
|
@@ -39,6 +50,29 @@ module Inferno
|
|
39
50
|
'SessionData'
|
40
51
|
end
|
41
52
|
|
53
|
+
def value_to_persist(params)
|
54
|
+
return nil if params[:value].blank?
|
55
|
+
|
56
|
+
case params[:type]&.to_s
|
57
|
+
when 'text', 'textarea', 'radio'
|
58
|
+
params[:value].to_s
|
59
|
+
when 'oauth_credentials'
|
60
|
+
credentials =
|
61
|
+
if params[:value].is_a? String
|
62
|
+
DSL::OAuthCredentials.new(JSON.parse(params[:value]))
|
63
|
+
elsif !params[:value].is_a? DSL::OAuthCredentials
|
64
|
+
raise Exceptions::BadSessionDataType.new(params[:name], DSL::OAuthCredentials, params[:value].class)
|
65
|
+
else
|
66
|
+
params[:value]
|
67
|
+
end
|
68
|
+
|
69
|
+
credentials.name = params[:name]
|
70
|
+
credentials.to_s
|
71
|
+
else
|
72
|
+
raise Exceptions::UnknownSessionDataType, params
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
42
76
|
class Model < Sequel::Model(db)
|
43
77
|
many_to_one :test_session, class: 'Inferno::Repositories::TestSessions::Model', key: :test_session_id
|
44
78
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Inferno
|
2
|
+
# @private
|
3
|
+
# This class takes an array of results and determines the overall result. This
|
4
|
+
# is used to determine the result of a TestGroup/TestSuite based on the
|
5
|
+
# results of it's children.
|
6
|
+
class ResultSummarizer
|
7
|
+
attr_reader :results
|
8
|
+
|
9
|
+
def initialize(results)
|
10
|
+
@results = results
|
11
|
+
end
|
12
|
+
|
13
|
+
def summarize
|
14
|
+
prioritized_result_strings.find { |result_string| unique_result_strings.include? result_string }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def prioritized_result_strings
|
20
|
+
Entities::Result::RESULT_OPTIONS
|
21
|
+
end
|
22
|
+
|
23
|
+
def required_results
|
24
|
+
@required_results ||= results.select(&:required?)
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_optional_results?
|
28
|
+
required_results.blank?
|
29
|
+
end
|
30
|
+
|
31
|
+
def results_for_summary
|
32
|
+
all_optional_results? ? results : required_results
|
33
|
+
end
|
34
|
+
|
35
|
+
def unique_result_strings
|
36
|
+
@unique_result_strings ||=
|
37
|
+
results_for_summary.map(&:result).uniq
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/inferno/spec_support.rb
CHANGED
data/lib/inferno/test_runner.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative './result_summarizer'
|
1
2
|
require_relative './utils/markdown_formatter'
|
2
3
|
|
3
4
|
module Inferno
|
@@ -120,7 +121,9 @@ module Inferno
|
|
120
121
|
|
121
122
|
children = parent.children
|
122
123
|
child_results = results_repo.current_results_for_test_session_and_runnables(test_session.id, children)
|
123
|
-
|
124
|
+
required_children = children.select(&:required?)
|
125
|
+
required_results = child_results.select(&:required?)
|
126
|
+
return if required_children.length != required_results.length
|
124
127
|
|
125
128
|
old_result = results_repo.current_result_for_test_session(test_session.id, parent.reference_hash)&.result
|
126
129
|
new_result = roll_up_result(child_results)
|
@@ -137,16 +140,21 @@ module Inferno
|
|
137
140
|
def load_inputs(runnable)
|
138
141
|
runnable.inputs.each_with_object({}) do |input_identifier, input_hash|
|
139
142
|
input_alias = runnable.config.input_name(input_identifier)
|
140
|
-
|
143
|
+
input_type = runnable.config.input_type(input_identifier)
|
144
|
+
input_hash[input_identifier] =
|
145
|
+
session_data_repo.load(test_session_id: test_session.id, name: input_alias, type: input_type)
|
141
146
|
end
|
142
147
|
end
|
143
148
|
|
144
149
|
def save_outputs(runnable_instance)
|
145
150
|
outputs =
|
146
151
|
runnable_instance.outputs_to_persist.map do |output_identifier, value|
|
152
|
+
output_name = runnable_instance.class.config.output_name(output_identifier)
|
153
|
+
output_type = runnable_instance.class.config.output_type(output_identifier)
|
147
154
|
{
|
148
|
-
name:
|
149
|
-
|
155
|
+
name: output_name,
|
156
|
+
type: output_type,
|
157
|
+
value: value.to_s
|
150
158
|
}
|
151
159
|
end
|
152
160
|
|
@@ -165,11 +173,7 @@ module Inferno
|
|
165
173
|
end
|
166
174
|
|
167
175
|
def roll_up_result(results)
|
168
|
-
|
169
|
-
unique_results = results.map(&:result).uniq
|
170
|
-
result_priority.find do |result|
|
171
|
-
unique_results.include? result
|
172
|
-
end
|
176
|
+
ResultSummarizer.new(results).summarize
|
173
177
|
end
|
174
178
|
end
|
175
179
|
end
|
data/lib/inferno/version.rb
CHANGED
data/spec/factories/request.rb
CHANGED
data/spec/factories/result.rb
CHANGED
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :result, class: 'Inferno::Entities::Result' do
|
3
3
|
transient do
|
4
4
|
runnable { test_run.runnable.reference_hash }
|
5
|
-
test_run
|
5
|
+
test_run { repo_create(:test_run) }
|
6
6
|
test_session { test_run.test_session }
|
7
7
|
message_count { 0 }
|
8
8
|
request_count { 0 }
|
@@ -23,7 +23,7 @@ FactoryBot.define do
|
|
23
23
|
before(:create) do |instance, evaluator|
|
24
24
|
instance.instance_variable_set(
|
25
25
|
:@requests,
|
26
|
-
|
26
|
+
build_list(:request, evaluator.request_count, result: instance)
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inferno_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -502,6 +502,7 @@ files:
|
|
502
502
|
- lib/inferno/db/migrations/003_update_session_data.rb
|
503
503
|
- lib/inferno/db/migrations/004_add_request_results_table.rb
|
504
504
|
- lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb
|
505
|
+
- lib/inferno/db/migrations/006_remove_unused_tables.rb
|
505
506
|
- lib/inferno/db/schema.rb
|
506
507
|
- lib/inferno/dsl.rb
|
507
508
|
- lib/inferno/dsl/assertions.rb
|
@@ -511,6 +512,7 @@ files:
|
|
511
512
|
- lib/inferno/dsl/fhir_validation.rb
|
512
513
|
- lib/inferno/dsl/http_client.rb
|
513
514
|
- lib/inferno/dsl/http_client_builder.rb
|
515
|
+
- lib/inferno/dsl/oauth_credentials.rb
|
514
516
|
- lib/inferno/dsl/request_storage.rb
|
515
517
|
- lib/inferno/dsl/results.rb
|
516
518
|
- lib/inferno/dsl/resume_test_route.rb
|
@@ -518,6 +520,7 @@ files:
|
|
518
520
|
- lib/inferno/entities.rb
|
519
521
|
- lib/inferno/entities/attributes.rb
|
520
522
|
- lib/inferno/entities/entity.rb
|
523
|
+
- lib/inferno/entities/has_runnable.rb
|
521
524
|
- lib/inferno/entities/header.rb
|
522
525
|
- lib/inferno/entities/message.rb
|
523
526
|
- lib/inferno/entities/request.rb
|
@@ -529,6 +532,7 @@ files:
|
|
529
532
|
- lib/inferno/entities/test_session.rb
|
530
533
|
- lib/inferno/entities/test_suite.rb
|
531
534
|
- lib/inferno/exceptions.rb
|
535
|
+
- lib/inferno/ext/fhir_client.rb
|
532
536
|
- lib/inferno/jobs.rb
|
533
537
|
- lib/inferno/jobs/execute_test_run.rb
|
534
538
|
- lib/inferno/jobs/resume_test_run.rb
|
@@ -554,6 +558,7 @@ files:
|
|
554
558
|
- lib/inferno/repositories/test_suites.rb
|
555
559
|
- lib/inferno/repositories/tests.rb
|
556
560
|
- lib/inferno/repositories/validate_runnable_reference.rb
|
561
|
+
- lib/inferno/result_summarizer.rb
|
557
562
|
- lib/inferno/spec_support.rb
|
558
563
|
- lib/inferno/test_runner.rb
|
559
564
|
- lib/inferno/utils/markdown_formatter.rb
|