Class: Inferno::Entities::TestGroup

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, DSL::FHIRClient::ClassMethods, DSL::HTTPClient::ClassMethods, DSL::Runnable
Includes:
DSL::Assertions, DSL::FHIRValidation, DSL::FhirpathEvaluation, DSL::Messages, DSL::Results
Defined in:
lib/inferno/entities/test_group.rb

Constant Summary

Constants included from DSL::Runnable

DSL::Runnable::VARIABLES_NOT_TO_COPY

Instance Attribute Summary collapse

Attributes included from DSL::Runnable

#parent, #suite_option_requirements

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::FHIRClient::ClassMethods

fhir_client, fhir_client_definitions

Methods included from DSL::HTTPClient::ClassMethods

http_client, http_client_definitions

Methods included from DSL::Runnable

add_self_to_repository, all_children, block, child_metadata, children, configure_child_class, copy_instance_variables, create_child_class, default_id, define_child, description, extended, handle_child_definition_block, id, input_instructions, inspect, optional, optional?, process_args, repository, required, required?, required_suite_options, resume_test_route, route, short_description, short_title, suite, suite_endpoint, test_count, title, user_runnable?

Methods included from Utils::MarkdownFormatter

#format_markdown

Methods included from DSL::Messages

#add_message, #info, #messages, #warning

Methods included from DSL::Assertions

#assert, #assert_resource_type, #assert_response_content_type, #assert_response_status, #assert_valid_bundle_entries, #assert_valid_http_uri, #assert_valid_json, #assert_valid_resource, #bad_content_type_message, #bad_resource_type_message, #bad_response_status_message, #invalid_bundle_entries_message, #invalid_resource_message, #no_content_type_message, #normalize_resource_type, #normalize_types_to_check

Methods included from DSL::Results

#cancel, #identifier, #omit, #omit_if, #pass, #pass_if, #skip, #skip_if, #wait, #wait_timeout

Methods included from DSL::FhirpathEvaluation

#evaluate_fhirpath, included

Methods included from DSL::FHIRValidation

#find_validator, included, #resource_is_valid?

Constructor Details

#initializeTestGroup

Returns a new instance of TestGroup.



23
24
25
# File 'lib/inferno/entities/test_group.rb', line 23

def initialize
  @results = Inferno::ResultCollection.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/inferno/entities/test_group.rb', line 28

def method_missing(name, ...)
  parent_instance = self.class.parent&.new
  if parent_instance.respond_to?(name)
    parent_instance.send(name, ...)
  else
    super
  end
end

Instance Attribute Details

#result_messageObject

Returns the value of attribute result_message.



20
21
22
# File 'lib/inferno/entities/test_group.rb', line 20

def result_message
  @result_message
end

#resultsObject

Returns the value of attribute results.



20
21
22
# File 'lib/inferno/entities/test_group.rb', line 20

def results
  @results
end

Class Method Details

.default_idObject



108
109
110
111
112
113
# File 'lib/inferno/entities/test_group.rb', line 108

def default_id
  return name if name.present?

  suffix = parent ? (parent.groups.find_index(self) + 1).to_s.rjust(2, '0') : SecureRandom.uuid
  "Group#{suffix}"
end

.groupvoid

This method returns an undefined value.

Add a child group



70
71
72
73
# File 'lib/inferno/entities/test_group.rb', line 70

def group(...)
  ()
  define_child(...)
end

.group_metadataObject



83
84
85
86
87
88
# File 'lib/inferno/entities/test_group.rb', line 83

def 
  {
    class: TestGroup,
    repo: repository
  }
end

.groups(options = nil) ⇒ Array<Inferno::Entities::TestGroup>

Get this group’s child groups, filtered by suite options, if provided.

Parameters:

Returns:



53
54
55
# File 'lib/inferno/entities/test_group.rb', line 53

def groups(options = nil)
  children(options).select { |child| child < Inferno::Entities::TestGroup }
end

.reference_hashObject



116
117
118
119
120
# File 'lib/inferno/entities/test_group.rb', line 116

def reference_hash
  {
    test_group_id: id
  }
end

.repositoryObject



44
45
46
# File 'lib/inferno/entities/test_group.rb', line 44

def repository
  Inferno::Repositories::TestGroups.new
end

.run_as_group(value = true) ⇒ void

This method returns an undefined value.

When true, this group’s children can not be run individually in the UI, and this group must be run as a group.

Parameters:

  • value (Boolean) (defaults to: true)


127
128
129
# File 'lib/inferno/entities/test_group.rb', line 127

def run_as_group(value = true) # rubocop:disable Style/OptionalBooleanParameter
  @run_as_group = value
end

.run_as_group?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/inferno/entities/test_group.rb', line 132

def run_as_group?
  @run_as_group || false
end

.short_idString

Returns A short numeric id which is displayed in the UI.

Returns:

  • (String)

    A short numeric id which is displayed in the UI



99
100
101
102
103
104
105
# File 'lib/inferno/entities/test_group.rb', line 99

def short_id
  @short_id ||= begin
    prefix = parent.respond_to?(:short_id) ? "#{parent.short_id}." : ''
    suffix = parent ? (parent.groups.find_index(self) + 1).to_s : 'X'
    "#{prefix}#{suffix}"
  end
end

.testvoid

This method returns an undefined value.

Add a test



77
78
79
80
# File 'lib/inferno/entities/test_group.rb', line 77

def test(...)
  ()
  define_child(...)
end

.test_metadataObject



91
92
93
94
95
96
# File 'lib/inferno/entities/test_group.rb', line 91

def 
  {
    class: Test,
    repo: Inferno::Repositories::Tests.new
  }
end

.tests(options = nil) ⇒ Array<Inferno::Entities::Test>

Get this group’s child tests, filtered by suite options, if provided.

Parameters:

Returns:



62
63
64
# File 'lib/inferno/entities/test_group.rb', line 62

def tests(options = nil)
  children(options).select { |child| child < Inferno::Entities::Test }
end

Instance Method Details

#respond_to_missing?(name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/inferno/entities/test_group.rb', line 38

def respond_to_missing?(name, _include_private = false)
  self.class.parent&.new&.respond_to?(name)
end