inferno_core 0.0.5 → 0.0.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.
@@ -1,19 +1,23 @@
1
1
  require_relative '../dsl'
2
2
  require_relative '../repositories/tests'
3
+ require_relative '../utils/markdown_formatter'
4
+ require 'pry'
3
5
 
4
6
  module Inferno
5
7
  module Entities
6
8
  class Test
7
9
  extend Forwardable
8
10
  include DSL
11
+ include Inferno::Utils::MarkdownFormatter
9
12
 
10
13
  def_delegators 'self.class', :title, :id, :block, :inputs, :outputs
11
14
 
12
15
  attr_accessor :result_message
13
- attr_reader :test_session_id
16
+ attr_reader :test_session_id, :scratch
14
17
 
15
18
  def initialize(**params)
16
19
  params[:inputs]&.each { |key, value| instance_variable_set("@#{key}", value) }
20
+ @scratch = params[:scratch]
17
21
  @test_session_id = params[:test_session_id]
18
22
  end
19
23
 
@@ -22,7 +26,7 @@ module Inferno
22
26
  end
23
27
 
24
28
  def add_message(type, message)
25
- messages << { type: type.to_s, message: message }
29
+ messages << { type: type.to_s, message: format_markdown(message) }
26
30
  end
27
31
 
28
32
  # Set output values. Once set, these values will be available to any
@@ -33,11 +37,21 @@ module Inferno
33
37
  # @example
34
38
  # output(patient_id: '5', bearer_token: 'ABC')
35
39
  def output(outputs)
40
+ # TODO: update to track outputs that need to be updated
36
41
  outputs.each do |key, value|
37
42
  send("#{key}=", value)
43
+ outputs_to_persist[key] = value
38
44
  end
39
45
  end
40
46
 
47
+ # @api private
48
+ # A hash containing outputs that have been set during execution and need
49
+ # to be persisted. A test may not always update all outputs, so this is
50
+ # used to prevent overwriting an output with nil when it wasn't updated.
51
+ def outputs_to_persist
52
+ @outputs_to_persist ||= {}
53
+ end
54
+
41
55
  # Add an informational message to the results of a test. If passed a
42
56
  # block, a failed assertion will become an info message and test execution
43
57
  # will continue.
@@ -79,6 +79,14 @@ module Inferno
79
79
  test_group_id: id
80
80
  }
81
81
  end
82
+
83
+ def run_as_group(value = true) # rubocop:disable Style/OptionalBooleanParameter
84
+ @run_as_group = value
85
+ end
86
+
87
+ def run_as_group?
88
+ @run_as_group || false
89
+ end
82
90
  end
83
91
  end
84
92
  end
@@ -50,5 +50,17 @@ module Inferno
50
50
  super("No '#{validator_name}' validator found")
51
51
  end
52
52
  end
53
+
54
+ class RequiredInputsNotFound < RuntimeError
55
+ def initialize(missing_inputs)
56
+ super("Missing the following required inputs: #{missing_inputs.join(', ')}")
57
+ end
58
+ end
59
+
60
+ class NotUserRunnableException < RuntimeError
61
+ def initialize
62
+ super('The chosen runnable must be run as part of a group')
63
+ end
64
+ end
53
65
  end
54
66
  end