inferno_core 0.0.8 → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,22 +4,33 @@ module Inferno
4
4
  def save(params)
5
5
  name = params[:name].to_s.downcase
6
6
  test_session_id = params[:test_session_id]
7
+
8
+ value = value_to_persist(params)
9
+
7
10
  db
8
11
  .insert_conflict(
9
12
  target: :id,
10
- update: { value: params[:value] }
13
+ update: { value: value }
11
14
  ).insert(
12
15
  id: "#{test_session_id}_#{name}",
13
16
  name: name,
14
- value: params[:value],
17
+ value: value,
15
18
  test_session_id: test_session_id
16
19
  )
17
20
  end
18
21
 
19
- def load(test_session_id:, name:)
20
- self.class::Model
21
- .find(test_session_id: test_session_id, name: name.to_s.downcase)
22
- &.value
22
+ def load(test_session_id:, name:, type: 'text')
23
+ raw_value =
24
+ self.class::Model
25
+ .find(test_session_id: test_session_id, name: name.to_s.downcase)
26
+ &.value
27
+
28
+ case type.to_s
29
+ when 'oauth_credentials'
30
+ DSL::OAuthCredentials.new(JSON.parse(raw_value))
31
+ else
32
+ raw_value
33
+ end
23
34
  end
24
35
 
25
36
  def get_all_from_session(test_session_id)
@@ -39,6 +50,29 @@ module Inferno
39
50
  'SessionData'
40
51
  end
41
52
 
53
+ def value_to_persist(params)
54
+ return nil if params[:value].blank?
55
+
56
+ case params[:type]&.to_s
57
+ when 'text', 'textarea'
58
+ params[:value].to_s
59
+ when 'oauth_credentials'
60
+ credentials =
61
+ if params[:value].is_a? String
62
+ DSL::OAuthCredentials.new(JSON.parse(params[:value]))
63
+ elsif !params[:value].is_a? DSL::OAuthCredentials
64
+ raise Exceptions::BadSessionDataType.new(params[:name], DSL::OAuthCredentials, params[:value].class)
65
+ else
66
+ params[:value]
67
+ end
68
+
69
+ credentials.name = params[:name]
70
+ credentials.to_s
71
+ else
72
+ raise Exceptions::UnknownSessionDataType, params
73
+ end
74
+ end
75
+
42
76
  class Model < Sequel::Model(db)
43
77
  many_to_one :test_session, class: 'Inferno::Repositories::TestSessions::Model', key: :test_session_id
44
78
  end
@@ -1,5 +1,5 @@
1
1
  module Inferno
2
- # @private
2
+ # @api private
3
3
  # This module provides constants so that unit tests in suite repositories can
4
4
  # load the factories defined in inferno.
5
5
  module SpecSupport
@@ -137,16 +137,21 @@ module Inferno
137
137
  def load_inputs(runnable)
138
138
  runnable.inputs.each_with_object({}) do |input_identifier, input_hash|
139
139
  input_alias = runnable.config.input_name(input_identifier)
140
- input_hash[input_identifier] = session_data_repo.load(test_session_id: test_session.id, name: input_alias)
140
+ input_type = runnable.config.input_type(input_identifier)
141
+ input_hash[input_identifier] =
142
+ session_data_repo.load(test_session_id: test_session.id, name: input_alias, type: input_type)
141
143
  end
142
144
  end
143
145
 
144
146
  def save_outputs(runnable_instance)
145
147
  outputs =
146
148
  runnable_instance.outputs_to_persist.map do |output_identifier, value|
149
+ output_name = runnable_instance.class.config.output_name(output_identifier)
150
+ output_type = runnable_instance.class.config.output_type(output_identifier)
147
151
  {
148
- name: runnable_instance.class.config.output_name(output_identifier),
149
- value: value
152
+ name: output_name,
153
+ type: output_type,
154
+ value: value.to_s
150
155
  }
151
156
  end
152
157
 
@@ -1,3 +1,3 @@
1
1
  module Inferno
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.1.0.pre'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :request, class: 'Inferno::Entities::Request' do
3
3
  transient do
4
- result
4
+ result { repo_create(:result, request_count: 0) }
5
5
  header_count { 2 }
6
6
  end
7
7
 
@@ -2,7 +2,7 @@ FactoryBot.define do
2
2
  factory :result, class: 'Inferno::Entities::Result' do
3
3
  transient do
4
4
  runnable { test_run.runnable.reference_hash }
5
- test_run
5
+ test_run { repo_create(:test_run) }
6
6
  test_session { test_run.test_session }
7
7
  message_count { 0 }
8
8
  request_count { 0 }
@@ -23,7 +23,7 @@ FactoryBot.define do
23
23
  before(:create) do |instance, evaluator|
24
24
  instance.instance_variable_set(
25
25
  :@requests,
26
- repo_create_list(:request, evaluator.request_count, result_id: instance.id)
26
+ build_list(:request, evaluator.request_count, result: instance)
27
27
  )
28
28
  end
29
29
 
@@ -2,6 +2,7 @@ module BasicTestSuite
2
2
  class AbcGroup < Inferno::Entities::TestGroup
3
3
  title 'ABC Group'
4
4
 
5
+ input :input1, :input2
5
6
  test 'demo_test' do
6
7
  1 + 1
7
8
  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.0.8
4
+ version: 0.1.0.pre
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: 2021-12-10 00:00:00.000000000 Z
13
+ date: 2022-01-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -502,6 +502,7 @@ files:
502
502
  - lib/inferno/db/migrations/003_update_session_data.rb
503
503
  - lib/inferno/db/migrations/004_add_request_results_table.rb
504
504
  - lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb
505
+ - lib/inferno/db/migrations/006_remove_unused_tables.rb
505
506
  - lib/inferno/db/schema.rb
506
507
  - lib/inferno/dsl.rb
507
508
  - lib/inferno/dsl/assertions.rb
@@ -511,6 +512,7 @@ files:
511
512
  - lib/inferno/dsl/fhir_validation.rb
512
513
  - lib/inferno/dsl/http_client.rb
513
514
  - lib/inferno/dsl/http_client_builder.rb
515
+ - lib/inferno/dsl/oauth_credentials.rb
514
516
  - lib/inferno/dsl/request_storage.rb
515
517
  - lib/inferno/dsl/results.rb
516
518
  - lib/inferno/dsl/resume_test_route.rb
@@ -529,6 +531,7 @@ files:
529
531
  - lib/inferno/entities/test_session.rb
530
532
  - lib/inferno/entities/test_suite.rb
531
533
  - lib/inferno/exceptions.rb
534
+ - lib/inferno/ext/fhir_client.rb
532
535
  - lib/inferno/jobs.rb
533
536
  - lib/inferno/jobs/execute_test_run.rb
534
537
  - lib/inferno/jobs/resume_test_run.rb
@@ -588,9 +591,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
588
591
  version: 2.7.0
589
592
  required_rubygems_version: !ruby/object:Gem::Requirement
590
593
  requirements:
591
- - - ">="
594
+ - - ">"
592
595
  - !ruby/object:Gem::Version
593
- version: '0'
596
+ version: 1.3.1
594
597
  requirements: []
595
598
  rubygems_version: 3.1.6
596
599
  signing_key: