inferno_core 0.3.3 → 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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/apps/web/controllers/test_runs/create.rb +8 -4
  3. data/lib/inferno/apps/web/controllers/test_sessions/create.rb +6 -3
  4. data/lib/inferno/apps/web/router.rb +5 -0
  5. data/lib/inferno/apps/web/serializers/input.rb +6 -2
  6. data/lib/inferno/apps/web/serializers/suite_option.rb +13 -0
  7. data/lib/inferno/apps/web/serializers/test.rb +4 -1
  8. data/lib/inferno/apps/web/serializers/test_group.rb +12 -3
  9. data/lib/inferno/apps/web/serializers/test_session.rb +5 -3
  10. data/lib/inferno/apps/web/serializers/test_suite.rb +10 -2
  11. data/lib/inferno/config/boot/db.rb +1 -1
  12. data/lib/inferno/config/boot/presets.rb +1 -1
  13. data/lib/inferno/config/boot.rb +1 -1
  14. data/lib/inferno/db/migrations/007_add_suite_options.rb +5 -0
  15. data/lib/inferno/db/schema.rb +1 -0
  16. data/lib/inferno/dsl/configurable.rb +1 -1
  17. data/lib/inferno/dsl/fhir_client.rb +22 -10
  18. data/lib/inferno/dsl/fhir_validation.rb +35 -12
  19. data/lib/inferno/dsl/http_client.rb +57 -35
  20. data/lib/inferno/dsl/http_client_builder.rb +6 -1
  21. data/lib/inferno/dsl/input_output_handling.rb +56 -42
  22. data/lib/inferno/dsl/runnable.rb +36 -10
  23. data/lib/inferno/dsl/suite_option.rb +40 -0
  24. data/lib/inferno/dsl/tcp_exception_handler.rb +11 -0
  25. data/lib/inferno/entities/input.rb +2 -1
  26. data/lib/inferno/entities/test.rb +7 -3
  27. data/lib/inferno/entities/test_group.rb +4 -4
  28. data/lib/inferno/entities/test_session.rb +40 -1
  29. data/lib/inferno/entities/test_suite.rb +18 -14
  30. data/lib/inferno/public/bundle.js +15 -15
  31. data/lib/inferno/repositories/presets.rb +10 -1
  32. data/lib/inferno/repositories/test_sessions.rb +24 -0
  33. data/lib/inferno/test_runner.rb +9 -3
  34. data/lib/inferno/version.rb +1 -1
  35. data/spec/support/factory_bot.rb +6 -0
  36. metadata +34 -2
@@ -1,3 +1,5 @@
1
+ require 'erb'
2
+
1
3
  require_relative 'in_memory_repository'
2
4
  require_relative '../entities/preset'
3
5
 
@@ -6,7 +8,14 @@ module Inferno
6
8
  # Repository that deals with persistence for the `Preset` entity.
7
9
  class Presets < InMemoryRepository
8
10
  def insert_from_file(path)
9
- preset_hash = JSON.parse(File.read(path))
11
+ case path
12
+ when /\.json$/
13
+ preset_hash = JSON.parse(File.read(path))
14
+ when /\.erb$/
15
+ templated = ERB.new(File.read(path)).result
16
+ preset_hash = JSON.parse(templated)
17
+ end
18
+
10
19
  preset_hash.deep_symbolize_keys!
11
20
  preset_hash[:id] ||= SecureRandom.uuid
12
21
  preset = Entities::Preset.new(preset_hash)
@@ -19,6 +19,18 @@ module Inferno
19
19
  }
20
20
  end
21
21
 
22
+ def create(params)
23
+ raw_suite_options = params[:suite_options]
24
+ suite_options =
25
+ if raw_suite_options.blank?
26
+ '[]'
27
+ else
28
+ JSON.generate(raw_suite_options.map(&:to_hash))
29
+ end
30
+
31
+ super(params.merge(suite_options: suite_options))
32
+ end
33
+
22
34
  def results_for_test_session(test_session_id)
23
35
  test_session_hash =
24
36
  self.class::Model
@@ -37,6 +49,18 @@ module Inferno
37
49
  end
38
50
  end
39
51
 
52
+ def build_entity(params)
53
+ suite_options = JSON.parse(params[:suite_options] || '[]').map do |suite_option_hash|
54
+ suite_option_hash.deep_symbolize_keys!
55
+ suite_option_hash[:id] = suite_option_hash[:id].to_sym
56
+ DSL::SuiteOption.new(suite_option_hash)
57
+ end
58
+
59
+ final_params = params.merge(suite_options: suite_options)
60
+ add_non_db_entities(final_params)
61
+ entity_class.new(final_params)
62
+ end
63
+
40
64
  class Model < Sequel::Model(db)
41
65
  include Import[test_suites_repo: 'repositories.test_suites']
42
66
 
@@ -62,7 +62,13 @@ module Inferno
62
62
  inputs = load_inputs(test)
63
63
  input_json_string = inputs_as_json(test, inputs)
64
64
 
65
- test_instance = test.new(inputs: inputs, test_session_id: test_session.id, scratch: scratch)
65
+ test_instance =
66
+ test.new(
67
+ inputs: inputs,
68
+ test_session_id: test_session.id,
69
+ scratch: scratch,
70
+ suite_options: test_session.suite_options_hash
71
+ )
66
72
 
67
73
  result = begin
68
74
  raise Exceptions::CancelException, 'Test cancelled by user' if test_run_is_cancelling
@@ -118,7 +124,7 @@ module Inferno
118
124
  end
119
125
 
120
126
  results = []
121
- group.children.each do |child|
127
+ group.children(test_session.suite_options).each do |child|
122
128
  result = run(child, scratch)
123
129
  results << result
124
130
  break if results.last.waiting?
@@ -137,7 +143,7 @@ module Inferno
137
143
  def update_parent_result(parent)
138
144
  return if parent.nil?
139
145
 
140
- children = parent.children
146
+ children = parent.children(test_session.suite_options)
141
147
  child_results = results_repo.current_results_for_test_session_and_runnables(test_session.id, children)
142
148
  required_children = children.select(&:required?)
143
149
  required_results = child_results.select(&:required?)
@@ -1,4 +1,4 @@
1
1
  module Inferno
2
2
  # Standard patterns for gem versions: https://guides.rubygems.org/patterns/
3
- VERSION = '0.3.3'.freeze
3
+ VERSION = '0.3.6'.freeze
4
4
  end
@@ -16,6 +16,12 @@ class CreateStrategy
16
16
 
17
17
  result
18
18
  end
19
+
20
+ # breaking change in factory_bot 6.2.1
21
+ # https://github.com/thoughtbot/factory_bot/issues/1536
22
+ def to_sym
23
+ :repo_create
24
+ end
19
25
  end
20
26
 
21
27
  FactoryBot.register_strategy(:repo_create, CreateStrategy)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inferno_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen MacVicar
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-05-25 00:00:00.000000000 Z
13
+ date: 2022-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -68,6 +68,20 @@ dependencies:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
70
  version: 0.12.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: dry-container
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.8.0
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '='
83
+ - !ruby/object:Gem::Version
84
+ version: 0.8.0
71
85
  - !ruby/object:Gem::Dependency
72
86
  name: dry-system
73
87
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +110,20 @@ dependencies:
96
110
  - - "~>"
97
111
  - !ruby/object:Gem::Version
98
112
  version: '1.2'
113
+ - !ruby/object:Gem::Dependency
114
+ name: faraday_middleware
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.2'
120
+ type: :runtime
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '1.2'
99
127
  - !ruby/object:Gem::Dependency
100
128
  name: fhir_client
101
129
  requirement: !ruby/object:Gem::Requirement
@@ -492,6 +520,7 @@ files:
492
520
  - lib/inferno/apps/web/serializers/result.rb
493
521
  - lib/inferno/apps/web/serializers/serializer.rb
494
522
  - lib/inferno/apps/web/serializers/session_data.rb
523
+ - lib/inferno/apps/web/serializers/suite_option.rb
495
524
  - lib/inferno/apps/web/serializers/test.rb
496
525
  - lib/inferno/apps/web/serializers/test_group.rb
497
526
  - lib/inferno/apps/web/serializers/test_run.rb
@@ -511,6 +540,7 @@ files:
511
540
  - lib/inferno/db/migrations/004_add_request_results_table.rb
512
541
  - lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb
513
542
  - lib/inferno/db/migrations/006_remove_unused_tables.rb
543
+ - lib/inferno/db/migrations/007_add_suite_options.rb
514
544
  - lib/inferno/db/schema.rb
515
545
  - lib/inferno/dsl.rb
516
546
  - lib/inferno/dsl/assertions.rb
@@ -526,6 +556,8 @@ files:
526
556
  - lib/inferno/dsl/results.rb
527
557
  - lib/inferno/dsl/resume_test_route.rb
528
558
  - lib/inferno/dsl/runnable.rb
559
+ - lib/inferno/dsl/suite_option.rb
560
+ - lib/inferno/dsl/tcp_exception_handler.rb
529
561
  - lib/inferno/entities.rb
530
562
  - lib/inferno/entities/attributes.rb
531
563
  - lib/inferno/entities/entity.rb