inferno_core 0.5.1 → 0.5.2

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: 2266ffdfdf00fea5f565f6b1d5f927ba0c6c64b4d5b5725b737bdb822fe231cd
4
- data.tar.gz: bfb17c44e6dabfb9ba46b153e25c1c62aaae6179eaf202505213ab920e4cbcca
3
+ metadata.gz: 41fdda8d351bb039a654949835c70ed19999cbce0ccba735b4154774cdc61225
4
+ data.tar.gz: 1c0a86692b2a231af565fd6695fcc229d0ea51c2acf55e4236a5ff551e0a83a9
5
5
  SHA512:
6
- metadata.gz: a12e012b24105c8f7e3feb22bd12612ccd4c0f4b345b3289d8fc0c946f1229581f476d1a984418e768b6c0baa65145fcd07f2dd27728ca76508328577de4812b
7
- data.tar.gz: f0aabd22881fddc9ad3292e15daf717dd5009fc63d46a947a2696c6d684b11ea239cd669d9e89a0efe0b0eb6233a04fe7e3ae4b8839fb024153a555d7b976fe7
6
+ metadata.gz: 5612c208f1aa22d56bdb168754e50c7dfb67d2b71a5b1699d42382f56994c782771d76865feb533cc1e87052d47540fd7d2fca5c708f5c2d02718c55b033c498
7
+ data.tar.gz: 6dd48102d0ba87b339f5534312a949f390b69ad26741e2be73db1ec287b281efa9842c814ca6e8a4250745597909111b10759b2d171711686025c060194dad61
@@ -44,10 +44,12 @@ module Inferno
44
44
 
45
45
  self.options = options
46
46
 
47
- outputter.print_start_message(options)
47
+ outputter.print_start_message(self.options)
48
+
49
+ load_preset_file_and_set_preset_id
48
50
 
49
51
  results = []
50
- outputter.print_around_run(options) do
52
+ outputter.print_around_run(self.options) do
51
53
  if all_selected_groups_and_tests.empty?
52
54
  test_run = create_test_run(suite)
53
55
  run_one(suite, test_run)
@@ -102,6 +104,18 @@ module Inferno
102
104
  @outputter ||= OUTPUTTERS[options[:outputter]].new
103
105
  end
104
106
 
107
+ def load_preset_file_and_set_preset_id
108
+ return unless options[:preset_file]
109
+ raise StandardError, 'Cannot use `--preset-id` and `--preset-file` options together' if options[:preset_id]
110
+
111
+ raise StandardError, "File #{options[:preset_file]} not found" unless File.exist? options[:preset_file]
112
+
113
+ options[:preset_id] = JSON.parse(File.read(options[:preset_file]))['id']
114
+ raise StandardError, "Preset #{options[:preset_file]} is missing id" if options[:preset_id].nil?
115
+
116
+ presets_repo.insert_from_file(options[:preset_file])
117
+ end
118
+
105
119
  def all_selected_groups_and_tests
106
120
  @all_selected_groups_and_tests ||= runnables_by_short_id + groups + tests
107
121
  end
@@ -109,7 +123,7 @@ module Inferno
109
123
  def run_one(runnable, test_run)
110
124
  verify_runnable(
111
125
  runnable,
112
- thor_hash_to_inputs_array(options[:inputs]),
126
+ thor_hash_to_inputs_array(inputs_and_preset),
113
127
  test_session.suite_options
114
128
  )
115
129
 
@@ -118,6 +132,33 @@ module Inferno
118
132
  dispatch_job(test_run)
119
133
  end
120
134
 
135
+ def inputs_and_preset
136
+ if preset
137
+ preset_inputs = preset.inputs.to_h do |preset_input|
138
+ [preset_input[:name], preset_input[:value]]
139
+ end
140
+
141
+ options.fetch(:inputs, {}).reverse_merge(preset_inputs)
142
+ else
143
+ options.fetch(:inputs, {})
144
+ end
145
+ end
146
+
147
+ def preset
148
+ return unless options[:preset_id]
149
+
150
+ @preset ||= presets_repo.find(options[:preset_id])
151
+
152
+ raise StandardError, "Preset #{options[:preset_id]} not found" if @preset.nil?
153
+
154
+ unless presets_repo.presets_for_suite(suite.id).include?(@preset)
155
+ raise StandardError,
156
+ "Preset #{options[:preset_id]} is incompatible with suite #{suite.id}"
157
+ end
158
+
159
+ @preset
160
+ end
161
+
121
162
  def suite
122
163
  @suite ||= Inferno::Repositories::TestSuites.new.find(options[:suite])
123
164
 
@@ -156,6 +197,10 @@ module Inferno
156
197
  @session_data_repo ||= Inferno::Repositories::SessionData.new
157
198
  end
158
199
 
200
+ def presets_repo
201
+ @presets_repo ||= Inferno::Repositories::Presets.new
202
+ end
203
+
159
204
  def test_session
160
205
  @test_session ||= test_sessions_repo.create({
161
206
  test_suite_id: suite.id,
@@ -169,7 +214,7 @@ module Inferno
169
214
  {
170
215
  test_session_id: test_session.id,
171
216
  runnable_id_key(runnable) => runnable.id,
172
- inputs: thor_hash_to_inputs_array(options[:inputs])
217
+ inputs: thor_hash_to_inputs_array(inputs_and_preset)
173
218
  }
174
219
  end
175
220
 
@@ -125,7 +125,15 @@ module Inferno
125
125
  option :inputs,
126
126
  aliases: ['-i'],
127
127
  type: :hash,
128
- desc: 'Inputs (i.e: --inputs=foo:bar goo:baz)'
128
+ desc: 'Inputs (i.e: --inputs=foo:bar goo:baz); will merge and override preset inputs'
129
+ option :preset_id,
130
+ aliases: ['-P'],
131
+ type: :string,
132
+ desc: 'Inferno preset id; cannot be used with `--preset-file`'
133
+ option :preset_file,
134
+ aliases: ['-p'],
135
+ type: :string,
136
+ desc: 'Path to an Inferno preset file for inputs; cannot be used with `--preset-id`'
129
137
  option :outputter,
130
138
  aliases: ['-o'],
131
139
  default: 'console',
@@ -142,7 +150,7 @@ module Inferno
142
150
  desc: 'Display this message'
143
151
  def execute
144
152
  Execute.boot_full_inferno
145
- Execute.new.run(options)
153
+ Execute.new.run(options.dup) # dup to unfreeze Thor options
146
154
  end
147
155
 
148
156
  # https://github.com/rails/thor/issues/244 - Make Thor exit(1) on Errors/Exceptions
@@ -1,6 +1,10 @@
1
1
  require 'hanami/middleware/body_parser'
2
2
  require_relative 'router'
3
3
 
4
+ # Only required to monkey patch the JSON parser to support application/fhir+json
5
+ require 'hanami/middleware/body_parser/json_parser'
6
+ require_relative '../../ext/json_parser'
7
+
4
8
  module Inferno
5
9
  module Web
6
10
  def self.app
@@ -9,10 +9,18 @@
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1" />
10
10
  <meta name="theme-color" content="#000000" />
11
11
  <meta id="base-path" name="base-path" content="<%= Inferno::Application['base_path'] %>">
12
- <meta
13
- name="description"
14
- content="FHIR Testing"
15
- />
12
+
13
+ <!-- Social media link unfurling meta tags -->
14
+ <title>Inferno Test Session</title>
15
+ <link rel="canonical" href="<%= Inferno::Application['base_url'] %>" />
16
+ <meta name="application-name" content="Inferno" />
17
+ <meta name="og:image" content="<%= Inferno::Application['inferno_host'] %><%= Inferno::Application['public_path'] %>/logo192.png" />
18
+ <meta name="og:type" content="website" />
19
+ <meta name="og:url" content="<%= Inferno::Application['base_url'] %>" />
20
+ <meta name="og:site_name" content="Inferno" />
21
+ <meta name="twitter:card" content="summary" />
22
+ <meta name="twitter:image" content="<%= Inferno::Application['inferno_host'] %><%= Inferno::Application['public_path'] %>/logo192.png" />
23
+
16
24
  <link rel="apple-touch-icon" href="<%= Inferno::Application['public_path'] %>/logo192.png" />
17
25
  <!--
18
26
  manifest.json provides metadata used when your web app is installed on a
@@ -10,5 +10,6 @@ Inferno::Application.register_provider(:executor) do
10
10
  end
11
11
 
12
12
  target_container.start :suites
13
+ target_container.start :presets
13
14
  end
14
15
  end
@@ -0,0 +1,11 @@
1
+ module Hanami
2
+ module Middleware
3
+ class BodyParser
4
+ class JsonParser
5
+ def self.mime_types
6
+ ['application/json', 'application/vnd.api+json', 'application/fhir+json']
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end