inferno_core 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40fa8983d93a7fc191a7d03bdb78c0bd80e138cfe5245d377c15f28360fb6b03
4
- data.tar.gz: 4aa592411c216c13bc55ebcef30ce2019522cc3575edc184fcb10593eb28239a
3
+ metadata.gz: 2f0cad7d368810c89ee2571e1f8aa6705d6b74b1ad058b8f179269a7705c2df7
4
+ data.tar.gz: 7f1ab19849ca3454f536b06963df78abc91c5dc7cbde24e796338836cd081e10
5
5
  SHA512:
6
- metadata.gz: bb0f7e9aafced3a1181cd40d8638f4ac07fefc0239ab771b85ce22aaec3785b7328ca82969cd83b1617051201fa149272ba80a53a05789129e6ee35302cf3a1b
7
- data.tar.gz: 5f14e0db2c0a2d3238198600a736790ea549ea11c91bb84578dda2e3de2270c31cb314b44972ec2fbc6635aa77b93f0ce4df2926d45c072745b19a1d6371b34f
6
+ metadata.gz: b7ff909be62d859f3a0755f787fb8d893edaadffd16cc70dd18f47cfe0184b2ec82330a7f51a02617c4b8afb6710e3282492a9a2f23cf82e37650548cbd9dd4b
7
+ data.tar.gz: 5832f7eb12e90626ebd9ca84e945a3afc631e5d63d024381548ed7c3fc373ff85ca9ea34533a79eefedb7e8ab8d80d65229d2fffd180c7d289586528b29dfb03
@@ -11,8 +11,8 @@ module Inferno
11
11
 
12
12
  PARAMS = [:test_session_id, :test_suite_id, :test_group_id, :test_id].freeze
13
13
 
14
- def verify_runnable(runnable, inputs)
15
- missing_inputs = runnable&.missing_inputs(inputs)
14
+ def verify_runnable(runnable, inputs, selected_suite_options)
15
+ missing_inputs = runnable&.missing_inputs(inputs, selected_suite_options)
16
16
  user_runnable = runnable&.user_runnable?
17
17
  raise Inferno::Exceptions::RequiredInputsNotFound, missing_inputs if missing_inputs&.any?
18
18
  raise Inferno::Exceptions::NotUserRunnableException unless user_runnable
@@ -26,7 +26,7 @@ module Inferno
26
26
  &.last
27
27
 
28
28
  if input.nil?
29
- Inferno::Application['logger'].warning(
29
+ Inferno::Application['logger'].warn(
30
30
  "Unknown input `#{input_params[:name]}` for #{test_run.runnable.id}: #{test_run.runnable.title}"
31
31
  )
32
32
  next
@@ -51,7 +51,11 @@ module Inferno
51
51
  return
52
52
  end
53
53
 
54
- verify_runnable(repo.build_entity(create_params(params)).runnable, params[:inputs])
54
+ verify_runnable(
55
+ repo.build_entity(create_params(params)).runnable,
56
+ params[:inputs],
57
+ test_session.suite_options
58
+ )
55
59
 
56
60
  test_run = repo.create(create_params(params).merge(status: 'queued'))
57
61
 
@@ -6,9 +6,8 @@ module Inferno
6
6
  PARAMS = [:test_suite_id, :suite_options].freeze
7
7
 
8
8
  def call(raw_params)
9
- query_params = raw_params.to_h
10
- body_params = JSON.parse(request.body.string).symbolize_keys
11
- params = query_params.merge(body_params)
9
+ params = raw_params.to_h
10
+ params.merge!(JSON.parse(request.body.string).symbolize_keys) unless request.body.string.blank?
12
11
 
13
12
  session = repo.create(create_params(params))
14
13
 
@@ -6,9 +6,13 @@ module Inferno
6
6
  class Input < Serializer
7
7
  identifier :name
8
8
 
9
- field :label, if: :field_present?
9
+ field :title, if: :field_present?
10
10
  field :description, if: :field_present?
11
- field :required, if: :field_present?
11
+ field :type, if: :field_present?
12
+ field :default, if: :field_present?
13
+ field :optional, if: :field_present?
14
+ field :options, if: :field_present?
15
+ field :locked, if: :field_present?
12
16
  field :value, if: :field_present?
13
17
  end
14
18
  end
@@ -7,7 +7,10 @@ module Inferno
7
7
  field :short_id
8
8
  field :title
9
9
  field :short_title
10
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
10
+ field :inputs do |test, options|
11
+ suite_options = options[:suite_options]
12
+ Input.render_as_hash(test.available_inputs(suite_options).values)
13
+ end
11
14
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
12
15
  field :description
13
16
  field :short_description
@@ -16,12 +16,17 @@ module Inferno
16
16
  field :optional?, name: :optional
17
17
 
18
18
  field :test_groups do |group, options|
19
- TestGroup.render_as_hash(group.groups(options[:suite_options]))
19
+ suite_options = options[:suite_options]
20
+ TestGroup.render_as_hash(group.groups(suite_options), suite_options: suite_options)
20
21
  end
21
22
  field :tests do |group, options|
22
- Test.render_as_hash(group.tests(options[:suite_options]))
23
+ suite_options = options[:suite_options]
24
+ Test.render_as_hash(group.tests(suite_options), suite_options: suite_options)
25
+ end
26
+ field :inputs do |group, options|
27
+ suite_options = options[:suite_options]
28
+ Input.render_as_hash(group.available_inputs(suite_options).values)
23
29
  end
24
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
25
30
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
26
31
  end
27
32
  end
@@ -11,6 +11,7 @@ module Inferno
11
11
  field :input_instructions
12
12
  field :test_count
13
13
  field :version
14
+ field :links
14
15
  association :suite_options, blueprint: SuiteOption
15
16
  association :presets, view: :summary, blueprint: Preset
16
17
  end
@@ -18,10 +19,14 @@ module Inferno
18
19
  view :full do
19
20
  include_view :summary
20
21
  field :test_groups do |suite, options|
21
- TestGroup.render_as_hash(suite.groups(options[:suite_options]))
22
+ suite_options = options[:suite_options]
23
+ TestGroup.render_as_hash(suite.groups(suite_options), suite_options: suite_options)
22
24
  end
23
25
  field :configuration_messages
24
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
26
+ field :inputs do |suite, options|
27
+ suite_options = options[:suite_options]
28
+ Input.render_as_hash(suite.available_inputs(suite_options).values)
29
+ end
25
30
  end
26
31
  end
27
32
  end
@@ -4,7 +4,7 @@ Inferno::Application.boot(:presets) do
4
4
  init do
5
5
  use :suites
6
6
 
7
- files_to_load = Dir.glob(File.join(Dir.pwd, 'config', 'presets', '*.json'))
7
+ files_to_load = Dir.glob(['config/presets/*.json', 'config/presets/*.json.erb'])
8
8
  files_to_load.map! { |path| File.realpath(path) }
9
9
  presets_repo = Inferno::Repositories::Presets.new
10
10
 
@@ -1,3 +1,5 @@
1
+ require 'faraday_middleware'
2
+
1
3
  require_relative 'request_storage'
2
4
  require_relative 'tcp_exception_handler'
3
5
 
@@ -75,7 +77,7 @@ module Inferno
75
77
  if client
76
78
  client.get(url, nil, options[:headers])
77
79
  elsif url.match?(%r{\Ahttps?://})
78
- Faraday.get(url, nil, options[:headers])
80
+ connection.get(url, nil, options[:headers])
79
81
  else
80
82
  raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
81
83
  end
@@ -83,6 +85,14 @@ module Inferno
83
85
  end
84
86
  end
85
87
 
88
+ # @private
89
+ def connection
90
+ Faraday.new do |f|
91
+ f.request :url_encoded
92
+ f.use FaradayMiddleware::FollowRedirects
93
+ end
94
+ end
95
+
86
96
  # Perform an HTTP POST request
87
97
  #
88
98
  # @param url [String] if this request is using a defined client, this will
@@ -103,7 +113,7 @@ module Inferno
103
113
  if client
104
114
  client.post(url, body, options[:headers])
105
115
  elsif url.match?(%r{\Ahttps?://})
106
- Faraday.post(url, body, options[:headers])
116
+ connection.post(url, body, options[:headers])
107
117
  else
108
118
  raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
109
119
  end
@@ -128,7 +138,7 @@ module Inferno
128
138
  if client
129
139
  client.delete(url, nil, options[:headers])
130
140
  elsif url.match?(%r{\Ahttps?://})
131
- Faraday.delete(url, nil, options[:headers])
141
+ connection.delete(url, nil, options[:headers])
132
142
  else
133
143
  raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
134
144
  end
@@ -167,7 +177,7 @@ module Inferno
167
177
  if client
168
178
  response = client.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
169
179
  elsif url.match?(%r{\Ahttps?://})
170
- response = Faraday.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
180
+ response = connection.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
171
181
  else
172
182
  raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
173
183
  end
@@ -1,3 +1,5 @@
1
+ require 'faraday_middleware'
2
+
1
3
  module Inferno
2
4
  module DSL
3
5
  # This module contains the HTTP DSL available to test writers.
@@ -12,7 +14,10 @@ module Inferno
12
14
  params = { url: url }
13
15
  params.merge!(headers: headers) if headers
14
16
 
15
- Faraday.new(params)
17
+ Faraday.new(params) do |f|
18
+ f.request :url_encoded
19
+ f.use FaradayMiddleware::FollowRedirects
20
+ end
16
21
  end
17
22
 
18
23
  # Define the base url for an HTTP client. A string or symbol can be
@@ -90,17 +90,17 @@ module Inferno
90
90
  end
91
91
 
92
92
  # @private
93
- def required_inputs
94
- available_inputs
93
+ def required_inputs(selected_suite_options)
94
+ available_inputs(selected_suite_options)
95
95
  .reject { |_, input| input.optional }
96
96
  .map { |_, input| input.name }
97
97
  end
98
98
 
99
99
  # @private
100
- def missing_inputs(submitted_inputs)
100
+ def missing_inputs(submitted_inputs, selected_suite_options)
101
101
  submitted_inputs = [] if submitted_inputs.nil?
102
102
 
103
- required_inputs.map(&:to_s) - submitted_inputs.map { |input| input[:name] }
103
+ required_inputs(selected_suite_options).map(&:to_s) - submitted_inputs.map { |input| input[:name] }
104
104
  end
105
105
 
106
106
  # Define a particular order for inputs to be presented in the API/UI
@@ -153,52 +153,46 @@ module Inferno
153
153
  # Inputs available for this runnable's children. A running list of outputs
154
154
  # created by the children is used to exclude any inputs which are provided
155
155
  # by an earlier child's output.
156
- def children_available_inputs
157
- @children_available_inputs ||=
158
- begin
159
- child_outputs = []
160
- all_children.each_with_object({}) do |child, definitions|
161
- new_definitions = child.available_inputs.map(&:dup)
162
- new_definitions.each do |input, new_definition|
163
- existing_definition = definitions[input]
164
-
165
- updated_definition =
166
- if existing_definition.present?
167
- existing_definition.merge_with_child(new_definition)
168
- else
169
- new_definition
170
- end
171
-
172
- next if child_outputs.include?(updated_definition.name.to_sym)
173
-
174
- definitions[updated_definition.name.to_sym] = updated_definition
156
+ def children_available_inputs(selected_suite_options = nil)
157
+ child_outputs = []
158
+ children(selected_suite_options).each_with_object({}) do |child, definitions|
159
+ new_definitions = child.available_inputs(selected_suite_options).map(&:dup)
160
+ new_definitions.each do |input, new_definition|
161
+ existing_definition = definitions[input]
162
+
163
+ updated_definition =
164
+ if existing_definition.present?
165
+ existing_definition.merge_with_child(new_definition)
166
+ else
167
+ new_definition
175
168
  end
176
169
 
177
- child_outputs.concat(child.all_outputs).uniq!
178
- end
170
+ next if child_outputs.include?(updated_definition.name.to_sym)
171
+
172
+ definitions[updated_definition.name.to_sym] = updated_definition
179
173
  end
174
+
175
+ child_outputs.concat(child.all_outputs).uniq!
176
+ end
180
177
  end
181
178
 
182
179
  # @private
183
180
  # Inputs available for the user for this runnable and all its children.
184
- def available_inputs
185
- @available_inputs ||=
186
- begin
187
- available_inputs =
188
- config.inputs
189
- .slice(*inputs)
190
- .each_with_object({}) do |(_, input), inputs|
191
- inputs[input.name.to_sym] = input
192
- end
193
-
194
- available_inputs.each do |input, current_definition|
195
- child_definition = children_available_inputs[input]
196
- current_definition.merge_with_child(child_definition)
181
+ def available_inputs(selected_suite_options = nil)
182
+ available_inputs =
183
+ config.inputs
184
+ .slice(*inputs)
185
+ .each_with_object({}) do |(_, input), inputs|
186
+ inputs[input.name.to_sym] = Entities::Input.new(input.to_hash)
197
187
  end
198
188
 
199
- available_inputs = children_available_inputs.merge(available_inputs)
200
- order_available_inputs(available_inputs)
201
- end
189
+ available_inputs.each do |input, current_definition|
190
+ child_definition = children_available_inputs(selected_suite_options)[input]
191
+ current_definition.merge_with_child(child_definition)
192
+ end
193
+
194
+ available_inputs = children_available_inputs(selected_suite_options).merge(available_inputs)
195
+ order_available_inputs(available_inputs)
202
196
  end
203
197
  end
204
198
  end
@@ -13,7 +13,8 @@ module Inferno
13
13
  :default,
14
14
  :optional,
15
15
  :options,
16
- :locked
16
+ :locked,
17
+ :value
17
18
  ].freeze
18
19
  include Entities::Attributes
19
20
 
@@ -93,6 +93,12 @@ module Inferno
93
93
  def suite_options
94
94
  @suite_options ||= []
95
95
  end
96
+
97
+ def links(links = nil)
98
+ return @links if links.nil?
99
+
100
+ @links = links
101
+ end
96
102
  end
97
103
  end
98
104
  end