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.
@@ -64,6 +64,22 @@ module Inferno
64
64
  end
65
65
  end
66
66
 
67
+ def update_non_db_entities_ids(hash, use_database_id: false)
68
+ key_map = {
69
+ test_id: Tests.new,
70
+ test_group_id: TestGroups.new,
71
+ test_suite_id: TestSuites.new
72
+ }
73
+
74
+ key_map.each do |key, repo|
75
+ next unless hash.key?(key)
76
+
77
+ entity = repo.find(hash[key])
78
+ hash[key] = use_database_id ? (entity&.database_id || hash[key]) : (entity&.id || hash[key])
79
+ break
80
+ end
81
+ end
82
+
67
83
  # Create a new record in the database.
68
84
  #
69
85
  # @param params [Hash]
@@ -76,7 +92,9 @@ module Inferno
76
92
  # # handle error
77
93
  # end
78
94
  def create(params)
95
+ update_non_db_entities_ids(params, use_database_id: true)
79
96
  result = self.class::Model.create(db_params(params))
97
+
80
98
  build_entity(result.to_hash.merge(handle_non_db_params(params)))
81
99
  end
82
100
 
@@ -100,6 +118,7 @@ module Inferno
100
118
  # @return [Object] an instance of `#entity_class`
101
119
  def build_entity(params)
102
120
  add_non_db_entities(params)
121
+ update_non_db_entities_ids(params)
103
122
  entity_class.new(params)
104
123
  end
105
124
 
@@ -57,7 +57,9 @@ module Inferno
57
57
  test_suite
58
58
  .requirement_sets
59
59
  .select do |set|
60
- set.suite_options.all? { |set_option| selected_suite_options.include? set_option }
60
+ set.suite_options.all? do |set_option|
61
+ selected_suite_options.blank? || selected_suite_options.include?(set_option)
62
+ end
61
63
  end
62
64
 
63
65
  requirements =
@@ -72,8 +74,7 @@ module Inferno
72
74
  .flat_map do |requirement_set|
73
75
  all.select do |requirement|
74
76
  requirement.requirement_set == requirement_set.identifier &&
75
- requirement.actor == requirement_set.actor &&
76
- requirement.tested?
77
+ requirement.actor == requirement_set.actor
77
78
  end
78
79
  end
79
80
  end
@@ -38,6 +38,7 @@ module Inferno
38
38
  # test_id: 'test_id'
39
39
  # )
40
40
  def current_result_for_test_session(test_session_id, params)
41
+ update_non_db_entities_ids(params, use_database_id: true)
41
42
  self.class::Model
42
43
  .where({ test_session_id: }.merge(params))
43
44
  .order(Sequel.desc(:updated_at))
@@ -63,10 +64,12 @@ module Inferno
63
64
  else
64
65
  {}
65
66
  end
67
+ update_non_db_entities_ids(params)
66
68
  entity_class.new(params.merge(runnable))
67
69
  end
68
70
 
69
71
  def result_for_test_run(params)
72
+ update_non_db_entities_ids(params, use_database_id: true)
70
73
  result_hash =
71
74
  self.class::Model
72
75
  .find(params)
@@ -202,9 +205,9 @@ module Inferno
202
205
  end
203
206
 
204
207
  def self.current_results_for_test_session_and_runnables(test_session_id, runnables)
205
- test_ids = runnables.select { |runnable| runnable < Entities::Test }.map!(&:id)
206
- test_group_ids = runnables.select { |runnable| runnable < Entities::TestGroup }.map!(&:id)
207
- test_suite_ids = runnables.select { |runnable| runnable < Entities::TestSuite }.map!(&:id)
208
+ test_ids = runnables.select { |runnable| runnable < Entities::Test }.map!(&:database_id)
209
+ test_group_ids = runnables.select { |runnable| runnable < Entities::TestGroup }.map!(&:database_id)
210
+ test_suite_ids = runnables.select { |runnable| runnable < Entities::TestSuite }.map!(&:database_id)
208
211
 
209
212
  fetch(
210
213
  current_results_sql(with_runnables_filter: true),
@@ -0,0 +1,29 @@
1
+ require_relative 'in_memory_repository'
2
+
3
+ module Inferno
4
+ module Repositories
5
+ class RunnableRepository < InMemoryRepository
6
+ def insert(entity)
7
+ raise Exceptions::DuplicateEntityIdException, entity.id if exists?(entity.id)
8
+
9
+ # Safety check to prevent rare database_id collisions from overwriting entries
10
+ if exists?(entity.database_id) && entity.database_id.to_s != entity.id.to_s
11
+ raise Exceptions::DuplicateEntityIdException,
12
+ "database_id: `#{entity.database_id}` generated from original id: `#{entity.id}`"
13
+ end
14
+
15
+ all << entity
16
+ all_by_id[entity.id.to_s] = entity
17
+ all_by_id[entity.database_id.to_s] = entity unless entity.database_id.to_s == entity.id.to_s
18
+
19
+ entity
20
+ end
21
+
22
+ def remove(entity)
23
+ super
24
+
25
+ all_by_id.delete(entity.database_id.to_s) unless entity.database_id.to_s == entity.id.to_s
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,9 +1,9 @@
1
- require_relative 'in_memory_repository'
1
+ require_relative 'runnable_repository'
2
2
 
3
3
  module Inferno
4
4
  module Repositories
5
5
  # Repository that deals with persistence for the `TestGroup` entity.
6
- class TestGroups < InMemoryRepository
6
+ class TestGroups < RunnableRepository
7
7
  end
8
8
  end
9
9
  end
@@ -60,6 +60,7 @@ module Inferno
60
60
 
61
61
  final_params = params.merge(suite_options:)
62
62
  add_non_db_entities(final_params)
63
+ update_non_db_entities_ids(final_params)
63
64
  entity_class.new(final_params)
64
65
  end
65
66
 
@@ -1,9 +1,9 @@
1
- require_relative 'in_memory_repository'
1
+ require_relative 'runnable_repository'
2
2
 
3
3
  module Inferno
4
4
  module Repositories
5
5
  # Repository that deals with persistence for the `TestSuite` entity.
6
- class TestSuites < InMemoryRepository
6
+ class TestSuites < RunnableRepository
7
7
  end
8
8
  end
9
9
  end
@@ -1,9 +1,9 @@
1
- require_relative 'in_memory_repository'
1
+ require_relative 'runnable_repository'
2
2
 
3
3
  module Inferno
4
4
  module Repositories
5
5
  # Repository that deals with persistence for the `Test` entity.
6
- class Tests < InMemoryRepository
6
+ class Tests < RunnableRepository
7
7
  end
8
8
  end
9
9
  end
@@ -4,6 +4,7 @@ require_relative 'repositories/test_groups'
4
4
  require_relative 'repositories/test_suites'
5
5
  require_relative 'repositories/tests'
6
6
  require_relative 'repositories/test_kits'
7
+ require_relative 'repositories/requirements'
7
8
 
8
9
  # Skip loading things which require the db when not necessary, such as CLI
9
10
  # commands which don't need the db
@@ -1,4 +1,4 @@
1
1
  module Inferno
2
2
  # Standard patterns for gem versions: https://guides.rubygems.org/patterns/
3
- VERSION = '0.6.11'.freeze
3
+ VERSION = '0.6.12'.freeze
4
4
  end
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.6.11
4
+ version: 0.6.12
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: 2025-05-30 00:00:00.000000000 Z
13
+ date: 2025-06-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -431,6 +431,7 @@ files:
431
431
  - lib/inferno/apps/cli/migration.rb
432
432
  - lib/inferno/apps/cli/new.rb
433
433
  - lib/inferno/apps/cli/requirements.rb
434
+ - lib/inferno/apps/cli/requirements_coverage_checker.rb
434
435
  - lib/inferno/apps/cli/requirements_exporter.rb
435
436
  - lib/inferno/apps/cli/services.rb
436
437
  - lib/inferno/apps/cli/suite.rb
@@ -494,6 +495,7 @@ files:
494
495
  - lib/inferno/apps/web/controllers/test_sessions/create.rb
495
496
  - lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb
496
497
  - lib/inferno/apps/web/controllers/test_sessions/results/index.rb
498
+ - lib/inferno/apps/web/controllers/test_sessions/results/io_value.rb
497
499
  - lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
498
500
  - lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb
499
501
  - lib/inferno/apps/web/controllers/test_sessions/show.rb
@@ -642,6 +644,7 @@ files:
642
644
  - lib/inferno/repositories/requests.rb
643
645
  - lib/inferno/repositories/requirements.rb
644
646
  - lib/inferno/repositories/results.rb
647
+ - lib/inferno/repositories/runnable_repository.rb
645
648
  - lib/inferno/repositories/session_data.rb
646
649
  - lib/inferno/repositories/tags.rb
647
650
  - lib/inferno/repositories/test_groups.rb