inferno_core 0.6.11 → 0.6.12

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.
@@ -9,33 +9,33 @@ module Inferno
9
9
  # @return [Array<Inferno::DSL::RequirementSet>]
10
10
  #
11
11
  # @example
12
- # class Suite < Inferno::TestSuite
13
- # requirement_sets(
14
- # {
15
- # identifier: 'example-regulation-1',
16
- # title: 'Example Regulation 1',
17
- # actor: 'Provider' # Only include requirements for the 'Provider'
18
- # # actor
19
- # },
20
- # {
21
- # identifier: 'example-ig-1',
22
- # title: 'Example Implementation Guide 1',
23
- # actor: 'Provider',
24
- # requirements: '2, 4-5' # Only include these specific requirements
25
- # },
26
- # {
27
- # identifier: 'example-ig-2',
28
- # title: 'Example Implementation Guide 2',
29
- # requirements: 'Referenced', # Only include requirements from this
30
- # # set that are referenced by other
31
- # # included requirements
32
- # actor: 'Server',
33
- # suite_options: { # Only include these requirements if the ig
34
- # ig_version: '3.0.0' # version 3.0.0 suite option is selected
12
+ # class Suite < Inferno::TestSuite
13
+ # requirement_sets(
14
+ # {
15
+ # identifier: 'example-regulation-1',
16
+ # title: 'Example Regulation 1',
17
+ # actor: 'Provider' # Only include requirements for the 'Provider'
18
+ # # actor
19
+ # },
20
+ # {
21
+ # identifier: 'example-ig-1',
22
+ # title: 'Example Implementation Guide 1',
23
+ # actor: 'Provider',
24
+ # requirements: '2, 4-5' # Only include these specific requirements
25
+ # },
26
+ # {
27
+ # identifier: 'example-ig-2',
28
+ # title: 'Example Implementation Guide 2',
29
+ # requirements: 'Referenced', # Only include requirements from this
30
+ # # set that are referenced by other
31
+ # # included requirements
32
+ # actor: 'Server',
33
+ # suite_options: { # Only include these requirements if the ig
34
+ # ig_version: '3.0.0' # version 3.0.0 suite option is selected
35
+ # }
35
36
  # }
36
- # }
37
- # )
38
- # end
37
+ # )
38
+ # end
39
39
  def requirement_sets(*sets)
40
40
  @requirement_sets = sets.map { |set| RequirementSet.new(**set) } if sets.present?
41
41
 
@@ -71,6 +71,45 @@ module Inferno
71
71
  def waiting?
72
72
  result == 'wait'
73
73
  end
74
+
75
+ def inputs
76
+ input_json.present? ? JSON.parse(input_json) : []
77
+ end
78
+
79
+ def outputs
80
+ output_json.present? ? JSON.parse(output_json) : []
81
+ end
82
+
83
+ # Flags large inputs or outputs and replaces their values with a reference message.
84
+ #
85
+ # This method inspects either the `inputs` or `outputs` array and,
86
+ # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
87
+ # and replaces the `value` with a message pointing to the full content endpoint.
88
+ #
89
+ # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
90
+ # @return [Array<Hash>] The mutated list of inputs or outputs.
91
+ def handle_large_io(io_type)
92
+ io_array = public_send(io_type)
93
+
94
+ io_array.each do |io|
95
+ next unless io_is_large?(io['value'])
96
+
97
+ io['is_large'] = true
98
+ io['value'] = <<~MESSAGE
99
+ #{io_type.singularize.capitalize} is too large to display, please visit
100
+ #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
101
+ for details
102
+ MESSAGE
103
+ end
104
+
105
+ io_array
106
+ end
107
+
108
+ # @private
109
+ def io_is_large?(io_value)
110
+ size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
111
+ size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
112
+ end
74
113
  end
75
114
  end
76
115
  end
@@ -149,6 +149,10 @@ module Inferno
149
149
  @options = suites.each_with_object({}) { |suite, hash| hash[suite.id] = suite.suite_options }
150
150
  end
151
151
 
152
+ def contains_test_suite?(test_suite_id)
153
+ suite_ids.map(&:to_sym).include? test_suite_id.to_sym
154
+ end
155
+
152
156
  # @private
153
157
  def add_self_to_repository
154
158
  repository.insert(self)