inferno_core 0.3.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c905fd9a450198c42daa6a7f3119277d1eeb1e39acb788856d90c3817719d02
4
- data.tar.gz: e11d6fcfa8acb3c487c62d512b9210db18f5d7bba5c9148063587de8a3e78420
3
+ metadata.gz: 40fa8983d93a7fc191a7d03bdb78c0bd80e138cfe5245d377c15f28360fb6b03
4
+ data.tar.gz: 4aa592411c216c13bc55ebcef30ce2019522cc3575edc184fcb10593eb28239a
5
5
  SHA512:
6
- metadata.gz: d62c7ebc7b9f9ac2024bfb933254cd54010b869fde72d15c77e935e7228096e2ba45844e3f8ba2f7b28f71315120d7a194b63d7e95675600e26efd1bbe822cc1
7
- data.tar.gz: ed6b0d392219155cd2cd6865e01d9ba838c067f36bfdd86ac10e80e923b51ddf688cff4f8e8a67e62e53a1d28c151f1c76d5e791166e920ff9832676fa1239c0
6
+ metadata.gz: bb0f7e9aafced3a1181cd40d8638f4ac07fefc0239ab771b85ce22aaec3785b7328ca82969cd83b1617051201fa149272ba80a53a05789129e6ee35302cf3a1b
7
+ data.tar.gz: 5f14e0db2c0a2d3238198600a736790ea549ea11c91bb84578dda2e3de2270c31cb314b44972ec2fbc6635aa77b93f0ce4df2926d45c072745b19a1d6371b34f
@@ -3,9 +3,13 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSessions
5
5
  class Create < Controller
6
- PARAMS = [:test_suite_id].freeze
6
+ PARAMS = [:test_suite_id, :suite_options].freeze
7
+
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)
7
12
 
8
- def call(params)
9
13
  session = repo.create(create_params(params))
10
14
 
11
15
  repo.apply_preset(session.id, params[:preset_id]) if params[:preset_id].present?
@@ -21,7 +25,7 @@ module Inferno
21
25
  end
22
26
 
23
27
  def create_params(params)
24
- params.to_h.slice(*PARAMS)
28
+ params.slice(*PARAMS)
25
29
  end
26
30
  end
27
31
  end
@@ -51,6 +51,11 @@ module Inferno
51
51
  send(route[:method], path, to: route[:handler])
52
52
  end
53
53
  end
54
+
55
+ Inferno::Repositories::TestSuites.all.map { |suite| "/#{suite.id}" }.each do |suite_path|
56
+ Application['logger'].info("Registering suite route: #{suite_path}")
57
+ get suite_path, to: ->(_env) { [200, {}, [client_page]] }
58
+ end
54
59
  end
55
60
  end
56
61
  end
@@ -0,0 +1,13 @@
1
+ module Inferno
2
+ module Web
3
+ module Serializers
4
+ class SuiteOption < Serializer
5
+ identifier :id
6
+ field :title, if: :field_present?
7
+ field :description, if: :field_present?
8
+ field :list_options, if: :field_present?
9
+ field :value, if: :field_present?
10
+ end
11
+ end
12
+ end
13
+ end
@@ -15,8 +15,12 @@ module Inferno
15
15
  field :user_runnable?, name: :user_runnable
16
16
  field :optional?, name: :optional
17
17
 
18
- association :groups, name: :test_groups, blueprint: TestGroup
19
- association :tests, blueprint: Test
18
+ field :test_groups do |group, options|
19
+ TestGroup.render_as_hash(group.groups(options[:suite_options]))
20
+ end
21
+ field :tests do |group, options|
22
+ Test.render_as_hash(group.tests(options[:suite_options]))
23
+ end
20
24
  field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
21
25
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
22
26
  end
@@ -1,3 +1,4 @@
1
+ require_relative 'suite_option'
1
2
  require_relative 'test_suite'
2
3
 
3
4
  module Inferno
@@ -7,10 +8,11 @@ module Inferno
7
8
  identifier :id
8
9
 
9
10
  field :test_suite_id
11
+ association :suite_options, blueprint: SuiteOption
10
12
 
11
- association :test_suite, blueprint: TestSuite, view: :full
12
- # association :test_runs, blueprint: TestRun
13
- # association :results, blueprint: Result
13
+ field :test_suite do |session, _options|
14
+ TestSuite.render_as_hash(session.test_suite, view: :full, suite_options: session.suite_options)
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -11,12 +11,15 @@ module Inferno
11
11
  field :input_instructions
12
12
  field :test_count
13
13
  field :version
14
+ association :suite_options, blueprint: SuiteOption
14
15
  association :presets, view: :summary, blueprint: Preset
15
16
  end
16
17
 
17
18
  view :full do
18
19
  include_view :summary
19
- association :groups, name: :test_groups, blueprint: TestGroup
20
+ field :test_groups do |suite, options|
21
+ TestGroup.render_as_hash(suite.groups(options[:suite_options]))
22
+ end
20
23
  field :configuration_messages
21
24
  field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
22
25
  end
@@ -0,0 +1,5 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column :test_sessions, :suite_options, String, text: true, size: 255
4
+ end
5
+ end
@@ -9,6 +9,7 @@ Sequel.migration do
9
9
  String :test_suite_id, :size=>255, :null=>false
10
10
  DateTime :created_at, :null=>false
11
11
  DateTime :updated_at, :null=>false
12
+ String :suite_options, :text=>true
12
13
 
13
14
  primary_key [:id]
14
15
  end
@@ -24,10 +24,20 @@ module Inferno
24
24
  [identifier, *other_identifiers].compact.each do |input_identifier|
25
25
  inputs << input_identifier
26
26
  config.add_input(input_identifier)
27
+ children
28
+ .reject { |child| child.inputs.include? input_identifier }
29
+ .each do |child|
30
+ child.input(input_identifier)
31
+ end
27
32
  end
28
33
  else
29
34
  inputs << identifier
30
35
  config.add_input(identifier, input_params)
36
+ children
37
+ .reject { |child| child.inputs.include? identifier }
38
+ .each do |child|
39
+ child.input(identifier, **input_params)
40
+ end
31
41
  end
32
42
  end
33
43
 
@@ -47,10 +57,20 @@ module Inferno
47
57
  [identifier, *other_identifiers].compact.each do |output_identifier|
48
58
  outputs << output_identifier
49
59
  config.add_output(output_identifier)
60
+ children
61
+ .reject { |child| child.outputs.include? output_identifier }
62
+ .each do |child|
63
+ child.output(output_identifier)
64
+ end
50
65
  end
51
66
  else
52
67
  outputs << identifier
53
68
  config.add_output(identifier, output_definition)
69
+ children
70
+ .reject { |child| child.outputs.include? identifier }
71
+ .each do |child|
72
+ child.output(identifier, **output_definition)
73
+ end
54
74
  end
55
75
  end
56
76
 
@@ -379,7 +379,7 @@ module Inferno
379
379
  end
380
380
 
381
381
  # @private
382
- def test_count(selected_suite_options = {})
382
+ def test_count(selected_suite_options = [])
383
383
  @test_counts ||= {}
384
384
 
385
385
  @test_counts[selected_suite_options] ||=
@@ -395,17 +395,23 @@ module Inferno
395
395
  end
396
396
 
397
397
  def required_suite_options(suite_option_requirements)
398
- @suite_option_requirements = 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
399
402
  end
400
403
 
401
- def children(selected_suite_options = nil)
404
+ def children(selected_suite_options = [])
402
405
  return all_children if selected_suite_options.blank?
403
406
 
404
407
  all_children.select do |child|
405
- requirements = child.suite_option_requirements || {}
408
+ requirements = child.suite_option_requirements
406
409
 
407
- # requirements are a subset of selected options or equal to selected options
408
- selected_suite_options >= requirements
410
+ if requirements.blank?
411
+ true
412
+ else
413
+ requirements.all? { |requirement| selected_suite_options.include? requirement }
414
+ end
409
415
  end
410
416
  end
411
417
  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
@@ -145,10 +145,12 @@ module Inferno
145
145
  # Define outputs for this Test
146
146
  #
147
147
  # @param output_definitions [Symbol]
148
+ # @param _output_params [Hash] Unused parameter. Just makes method
149
+ # signature compatible with `Inferno::DSL::InputOutputHandling.output`
148
150
  # @return [void]
149
151
  # @example
150
152
  # output :patient_id, :bearer_token
151
- def output(*output_definitions)
153
+ def output(*output_definitions, **_output_params)
152
154
  super
153
155
 
154
156
  output_definitions.each do |output|
@@ -31,12 +31,12 @@ module Inferno
31
31
  Inferno::Repositories::TestGroups.new
32
32
  end
33
33
 
34
- def groups
35
- all_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
- all_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
@@ -37,6 +37,34 @@ module Inferno
37
37
 
38
38
  def initialize(params)
39
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
40
68
  end
41
69
  end
42
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
 
@@ -30,8 +31,8 @@ module Inferno
30
31
  Inferno::Repositories::TestSuites.new
31
32
  end
32
33
 
33
- def groups
34
- all_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
@@ -86,11 +87,11 @@ module Inferno
86
87
  end
87
88
 
88
89
  def suite_option(identifier, **input_params)
89
- suite_options[identifier] = input_params
90
+ suite_options << DSL::SuiteOption.new(input_params.merge(id: identifier))
90
91
  end
91
92
 
92
93
  def suite_options
93
- @suite_options ||= {}
94
+ @suite_options ||= []
94
95
  end
95
96
  end
96
97
  end