From 203ffdf40f56eb441f90ef6ebf0e95d4ed1cc5df Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Fri, 18 Oct 2024 14:16:31 -0400 Subject: [PATCH 01/18] add test kit to template --- .../apps/cli/templates/%library_name%.gemspec.tt | 12 +++++++----- lib/inferno/apps/cli/templates/Dockerfile.tt | 1 + .../apps/cli/templates/lib/%library_name%.rb.tt | 2 ++ .../templates/lib/%library_name%/test_kit.rb.tt | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index 853e4e5f6..7c4fb78fa 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,12 +1,14 @@ +require_relative 'lib/<%= library_name %>/test_kit + Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = '0.0.1' - spec.authors = <%= authors %> + spec.version = TestKit.version + spec.authors = TestKit.authors # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = '<%= title_name %> Test Kit' - spec.description = '<%= human_name %> Inferno test kit for FHIR' - # spec.homepage = 'TODO' + spec.summary = TestKit.title + spec.description = TestKit.description + # spec.homepage = TestKit.repo spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' diff --git a/lib/inferno/apps/cli/templates/Dockerfile.tt b/lib/inferno/apps/cli/templates/Dockerfile.tt index d32710caf..ab3baf8da 100644 --- a/lib/inferno/apps/cli/templates/Dockerfile.tt +++ b/lib/inferno/apps/cli/templates/Dockerfile.tt @@ -6,6 +6,7 @@ RUN mkdir -p $INSTALL_PATH WORKDIR $INSTALL_PATH +ADD lib/<%= library_name %>/test_kit.rb $INSTALL_PATH/lib/<%= library_name %>/test_kit.rb ADD *.gemspec $INSTALL_PATH ADD Gemfile* $INSTALL_PATH RUN gem install bundler diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index 12e363228..32a73c67a 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -1,9 +1,11 @@ +require_relative '<%= library_name %>/test_kit' require_relative '<%= library_name %>/patient_group' module <%= module_name %> class Suite < Inferno::TestSuite id :<%= test_suite_id %> title '<%= title_name %> Test Suite' + version TestKit.version description '<%= human_name %> test suite.' # These inputs will be available to all tests in this suite diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt new file mode 100644 index 000000000..f2e215cb6 --- /dev/null +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt @@ -0,0 +1,16 @@ +module <%= module_name %> + class TestKit < Inferno::Entities::TestKit + id :us_core + title '<%= title_name %>' + description <<~DESCRIPTION + This is a big markdown description of the test kit. + DESCRIPTION + suite_ids [:<%= test_suite_id %>] + # tags ['SMART App Launch', 'US Core'] + # last_updated '2024-03-07' + version '0.0.1' + maturity 'Low' + authors <%= authors %> + # repo 'https://github.com/inferno-framework/us-core-test-kit' + end +end From 73e8e990ad358112d9bbc975a2b4476af858e5bd Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 24 Oct 2024 09:39:21 -0400 Subject: [PATCH 02/18] rename test kit to metadata --- .../apps/cli/templates/%library_name%.gemspec.tt | 12 ++++++------ lib/inferno/apps/cli/templates/Dockerfile.tt | 6 +++--- .../apps/cli/templates/lib/%library_name%.rb.tt | 4 ++-- .../{test_kit.rb.tt => metadata.rb.tt} | 2 +- lib/inferno/entities/test_kit.rb | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) rename lib/inferno/apps/cli/templates/lib/%library_name%/{test_kit.rb.tt => metadata.rb.tt} (90%) diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index 7c4fb78fa..b80fac7e7 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,14 +1,14 @@ -require_relative 'lib/<%= library_name %>/test_kit +require_relative 'lib/<%= library_name %>/metadata' Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = TestKit.version - spec.authors = TestKit.authors + spec.version = <%= module_name %>::Metadata.version + spec.authors = <%= module_name %>::Metadata.authors # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = TestKit.title - spec.description = TestKit.description - # spec.homepage = TestKit.repo + spec.summary = <%= module_name %>::Metadata.title + spec.description = <%= module_name %>::Metadata.description + # spec.homepage = <%= module_name %>::Metadata.repo spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' diff --git a/lib/inferno/apps/cli/templates/Dockerfile.tt b/lib/inferno/apps/cli/templates/Dockerfile.tt index ab3baf8da..19162984a 100644 --- a/lib/inferno/apps/cli/templates/Dockerfile.tt +++ b/lib/inferno/apps/cli/templates/Dockerfile.tt @@ -6,13 +6,13 @@ RUN mkdir -p $INSTALL_PATH WORKDIR $INSTALL_PATH -ADD lib/<%= library_name %>/test_kit.rb $INSTALL_PATH/lib/<%= library_name %>/test_kit.rb +ADD lib/<%= library_name %>/metadata.rb $INSTALL_PATH/lib/<%= library_name %>/metadata.rb ADD *.gemspec $INSTALL_PATH ADD Gemfile* $INSTALL_PATH RUN gem install bundler -# The below RUN line is commented out for development purposes, because any change to the +# The below RUN line is commented out for development purposes, because any change to the # required gems will break the dockerfile build process. -# If you want to run in Deploy mode, just run `bundle install` locally to update +# If you want to run in Deploy mode, just run `bundle install` locally to update # Gemfile.lock, and uncomment the following line. # RUN bundle config set --local deployment 'true' RUN bundle install diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index 32a73c67a..6eb29b35b 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -1,11 +1,11 @@ -require_relative '<%= library_name %>/test_kit' +require_relative '<%= library_name %>/metadata' require_relative '<%= library_name %>/patient_group' module <%= module_name %> class Suite < Inferno::TestSuite id :<%= test_suite_id %> title '<%= title_name %> Test Suite' - version TestKit.version + version Metadata.version description '<%= human_name %> test suite.' # These inputs will be available to all tests in this suite diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt similarity index 90% rename from lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt rename to lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt index f2e215cb6..b42662605 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt @@ -1,5 +1,5 @@ module <%= module_name %> - class TestKit < Inferno::Entities::TestKit + class Metadata < Inferno::TestKit id :us_core title '<%= title_name %>' description <<~DESCRIPTION diff --git a/lib/inferno/entities/test_kit.rb b/lib/inferno/entities/test_kit.rb index cf6adce84..a9a68ea85 100644 --- a/lib/inferno/entities/test_kit.rb +++ b/lib/inferno/entities/test_kit.rb @@ -6,7 +6,7 @@ module Entities # @example # # module USCoreTestKit - # class TestKit < Inferno::Entities::TestKit + # class Metadata < Inferno::Entities::TestKit # id :us_core # title 'US Core Test Kit' # description <<~DESCRIPTION From 9d85bbe2c27a7e8e71a408d8b157a8b9a8cee80b Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 24 Oct 2024 10:26:29 -0400 Subject: [PATCH 03/18] require test kit --- .../apps/cli/templates/lib/%library_name%/metadata.rb.tt | 2 ++ lib/inferno/entities.rb | 1 + lib/inferno/entities/test_kit.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt index b42662605..c2f0beac9 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt @@ -1,3 +1,5 @@ +require 'inferno/entities/test_kit' + module <%= module_name %> class Metadata < Inferno::TestKit id :us_core diff --git a/lib/inferno/entities.rb b/lib/inferno/entities.rb index 3158719b0..23cc87ba1 100644 --- a/lib/inferno/entities.rb +++ b/lib/inferno/entities.rb @@ -8,6 +8,7 @@ require_relative 'entities/session_data' require_relative 'entities/test' require_relative 'entities/test_group' +require_relative 'entities/test_kit' require_relative 'entities/test_run' require_relative 'entities/test_session' require_relative 'entities/test_suite' diff --git a/lib/inferno/entities/test_kit.rb b/lib/inferno/entities/test_kit.rb index a9a68ea85..ae075b650 100644 --- a/lib/inferno/entities/test_kit.rb +++ b/lib/inferno/entities/test_kit.rb @@ -168,4 +168,6 @@ def copy_instance_variables end end end + + TestKit = Entities::TestKit end From 95aa033014f243a24dff09f39cf7e3eb477f3ba4 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 24 Oct 2024 11:01:37 -0400 Subject: [PATCH 04/18] fix test kit id in template --- .../apps/cli/templates/lib/%library_name%/metadata.rb.tt | 2 +- lib/inferno/utils/named_thor_actions.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt index c2f0beac9..c63af4fc9 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt @@ -2,7 +2,7 @@ require 'inferno/entities/test_kit' module <%= module_name %> class Metadata < Inferno::TestKit - id :us_core + id :<%= test_kit_id %> title '<%= title_name %>' description <<~DESCRIPTION This is a big markdown description of the test kit. diff --git a/lib/inferno/utils/named_thor_actions.rb b/lib/inferno/utils/named_thor_actions.rb index 3fc55fba3..0e9217161 100644 --- a/lib/inferno/utils/named_thor_actions.rb +++ b/lib/inferno/utils/named_thor_actions.rb @@ -25,8 +25,12 @@ def title_name human_name.split.map(&:capitalize).join(' ') end + def test_kit_id + library_name.delete_suffix('_test_kit') + end + def test_suite_id - "#{library_name}_test_suite" + test_kit_id end end end From ed03bda5a0774fa1dbea7c6274442284f63022e1 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 24 Oct 2024 11:01:41 -0400 Subject: [PATCH 05/18] update specs --- spec/inferno/cli/new_spec.rb | 10 ++++------ spec/inferno/utils/named_thor_actions_spec.rb | 6 +++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/inferno/cli/new_spec.rb b/spec/inferno/cli/new_spec.rb index 2641174c4..5ca7a39ef 100644 --- a/spec/inferno/cli/new_spec.rb +++ b/spec/inferno/cli/new_spec.rb @@ -31,12 +31,10 @@ expect(File).to exist('test-fhir-app/test_fhir_app.gemspec') expect(File).to exist('test-fhir-app/lib/test_fhir_app.rb') - if cli_args.include? '--author' - expect(File.read('test-fhir-app/test_fhir_app.gemspec')).to match(/authors\s*=.*ABC/) - end - - if cli_args.count('--author') == 2 - expect(File.read('test-fhir-app/test_fhir_app.gemspec')).to match(/authors\s*=.*ABC.*DEF/) + if cli_args.count('--author') == 1 + expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include('authors ["ABC"]') + elsif cli_args.count('--author') == 2 + expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include('authors ["ABC", "DEF"]') end if cli_args.count('--implementation-guide') == 1 diff --git a/spec/inferno/utils/named_thor_actions_spec.rb b/spec/inferno/utils/named_thor_actions_spec.rb index 8e697beb9..0bce1d500 100644 --- a/spec/inferno/utils/named_thor_actions_spec.rb +++ b/spec/inferno/utils/named_thor_actions_spec.rb @@ -36,8 +36,12 @@ expect(dummy.title_name).to eq('Test Fhir App') end + it 'returns proper test kit id' do + expect(dummy.test_kit_id).to eq('test_fhir_app') + end + it 'returns proper test suite id' do - expect(dummy.test_suite_id).to eq('test_fhir_app_test_suite') + expect(dummy.test_suite_id).to eq('test_fhir_app') end end end From 67fc7099998cae91ec6ec48414be3291bb44058b Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 24 Oct 2024 11:22:54 -0400 Subject: [PATCH 06/18] fix test kit repo --- lib/inferno/entities/test_kit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inferno/entities/test_kit.rb b/lib/inferno/entities/test_kit.rb index ae075b650..80fcad415 100644 --- a/lib/inferno/entities/test_kit.rb +++ b/lib/inferno/entities/test_kit.rb @@ -156,7 +156,7 @@ def add_self_to_repository # @private def repository - @repository ||= Inferno::Repositories::TestKits + @repository ||= Inferno::Repositories::TestKits.new end # @private From 84a82e025dac1b59a0663f75ff8098a6bbe04f74 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Fri, 25 Oct 2024 13:11:46 -0400 Subject: [PATCH 07/18] update source code uri in gemspec --- lib/inferno/apps/cli/templates/%library_name%.gemspec.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index b80fac7e7..e857a74cc 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = 'TODO' + # spec.metadata['source_code_uri'] = <%= module_name %>::Metadata.repo spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], From 1e23e690e401626a91748f275b2aa65502284523 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 14 Nov 2024 12:55:49 -0500 Subject: [PATCH 08/18] WIP move test kit metadata to yaml file --- .../cli/templates/%library_name%.gemspec.tt | 17 ++++++++++------- .../cli/templates/lib/%library_name%.rb.tt | 1 - .../lib/%library_name%/metadata.rb.tt | 18 ------------------ .../lib/%library_name%/test_kit_metadata.yml | 16 ++++++++++++++++ lib/inferno/config/boot/suites.rb | 3 +-- lib/inferno/config/boot/test_kits.rb | 17 +++++++++++++++++ lib/inferno/entities/test_kit.rb | 1 + 7 files changed, 45 insertions(+), 28 deletions(-) delete mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt create mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml create mode 100644 lib/inferno/config/boot/test_kits.rb diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index e857a74cc..bbbd000e6 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,14 +1,16 @@ -require_relative 'lib/<%= library_name %>/metadata' +require 'yaml' + +test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml') Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = <%= module_name %>::Metadata.version - spec.authors = <%= module_name %>::Metadata.authors + spec.version = test_kit_metadata[:version] + spec.authors = test_kit_metadata[:authors] # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = <%= module_name %>::Metadata.title - spec.description = <%= module_name %>::Metadata.description - # spec.homepage = <%= module_name %>::Metadata.repo + spec.summary = test_kit_metadata[:title] + spec.description = test_kit_metadata[:description] + # spec.homepage = test_kit_metadata[:repo] spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' @@ -17,10 +19,11 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = <%= module_name %>::Metadata.repo + # spec.metadata['source_code_uri'] = test_kit_metadata[:repo] spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], + Dir['lib/**/*.yml'], 'LICENSE' ].flatten diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index 6eb29b35b..70ba5c046 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -1,4 +1,3 @@ -require_relative '<%= library_name %>/metadata' require_relative '<%= library_name %>/patient_group' module <%= module_name %> diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt deleted file mode 100644 index c63af4fc9..000000000 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt +++ /dev/null @@ -1,18 +0,0 @@ -require 'inferno/entities/test_kit' - -module <%= module_name %> - class Metadata < Inferno::TestKit - id :<%= test_kit_id %> - title '<%= title_name %>' - description <<~DESCRIPTION - This is a big markdown description of the test kit. - DESCRIPTION - suite_ids [:<%= test_suite_id %>] - # tags ['SMART App Launch', 'US Core'] - # last_updated '2024-03-07' - version '0.0.1' - maturity 'Low' - authors <%= authors %> - # repo 'https://github.com/inferno-framework/us-core-test-kit' - end -end diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml b/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml new file mode 100644 index 000000000..6c41f95e7 --- /dev/null +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml @@ -0,0 +1,16 @@ +id: <%= test_kit_id %> +title: <%= title_name %> +description: |- + This is a big markdown description of the test kit which + can span multiple lines +suite_ids: + - <%= test_suite_id %> +# tags: +# - SMART App Launch +# - US Core +# last_updated: '2024-03-07' +version: 0.0.1 +maturity: Low +authors: <% authors.each do |author|%> + - <%= author %> +<% end %># repo: 'https://github.com/inferno-framework/us-core-test-kit' diff --git a/lib/inferno/config/boot/suites.rb b/lib/inferno/config/boot/suites.rb index 58eaa257d..2c73df376 100644 --- a/lib/inferno/config/boot/suites.rb +++ b/lib/inferno/config/boot/suites.rb @@ -24,8 +24,7 @@ in_memory_entities_trace = TracePoint.trace(:end) do |trace| if trace.self < Inferno::Entities::Test || trace.self < Inferno::Entities::TestGroup || - trace.self < Inferno::Entities::TestSuite || - trace.self < Inferno::Entities::TestKit + trace.self < Inferno::Entities::TestSuite trace.self.add_self_to_repository end end diff --git a/lib/inferno/config/boot/test_kits.rb b/lib/inferno/config/boot/test_kits.rb new file mode 100644 index 000000000..625780aa9 --- /dev/null +++ b/lib/inferno/config/boot/test_kits.rb @@ -0,0 +1,17 @@ +require 'yaml' + +Inferno::Application.register_provider(:test_kits) do + prepare do + test_kit_gems = + Bundler + .definition + .specs + .select { |spec| spec.metadata.fetch('inferno_test_kit', 'false').casecmp? 'true' } + + test_kit_gems.each do |gem| + test_kit_metadata_path = File.join(gem.full_gem_path, 'lib', gem.name, 'test_kit_metadata.yml') + test_kit_metadata = YAML.safe_load_file(test_kit_metadata_path) + Inferno::Entities::TestKit.new(test_kit_metadata).add_self_to_repository + end + end +end diff --git a/lib/inferno/entities/test_kit.rb b/lib/inferno/entities/test_kit.rb index 80fcad415..49e4b7b95 100644 --- a/lib/inferno/entities/test_kit.rb +++ b/lib/inferno/entities/test_kit.rb @@ -5,6 +5,7 @@ module Inferno module Entities # @example # + # TODO: update this # module USCoreTestKit # class Metadata < Inferno::Entities::TestKit # id :us_core From 868b19375a1a51ab37e688d9b187e5b73203c1e8 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Tue, 19 Nov 2024 13:26:36 -0500 Subject: [PATCH 09/18] add test_kit method to suites --- lib/inferno/entities/test_suite.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/inferno/entities/test_suite.rb b/lib/inferno/entities/test_suite.rb index 2fe747869..2849d3fe8 100644 --- a/lib/inferno/entities/test_suite.rb +++ b/lib/inferno/entities/test_suite.rb @@ -186,6 +186,28 @@ def suite_summary(suite_summary = nil) @suite_summary = format_markdown(suite_summary) end + + def test_kit + @test_kit ||= + begin + suite_path = Object.const_source_location(name).first + suite_directory = File.dirname(suite_path) + + test_kit_gems = + Bundler + .definition + .specs + .select { |spec| spec.metadata.fetch('inferno_test_kit', 'false').casecmp? 'true' } + + test_kit_gem = test_kit_gems.find { |gem| suite_directory.start_with? gem.full_gem_path } + + test_kit_metadata_path = File.join(test_kit_gem, 'lib', test_kit_gem.name, 'test_kit_metadata.yml') + + test_kit_metadata = YAML.safe_load_file(test_kit_metadata_path) + + Repositories::TestKits.find(test_kit_metadata[:id]) + end + end end end end From aec09493d34da057abec39f47d6b856159a41b7c Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Tue, 19 Nov 2024 15:05:07 -0500 Subject: [PATCH 10/18] wip --- .../apps/cli/templates/%library_name%.gemspec.tt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index bbbd000e6..7b554d6a2 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,16 +1,16 @@ require 'yaml' -test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml') +test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml')) Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = test_kit_metadata[:version] - spec.authors = test_kit_metadata[:authors] + spec.version = test_kit_metadata['version'] + spec.authors = test_kit_metadata['authors'] # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = test_kit_metadata[:title] - spec.description = test_kit_metadata[:description] - # spec.homepage = test_kit_metadata[:repo] + spec.summary = test_kit_metadata['title'] + spec.description = test_kit_metadata['description'] + # spec.homepage = test_kit_metadata['repo'] spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' @@ -18,8 +18,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rspec', '~> 3.10' spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') + spec.metadata['inferno_test_kit'] = 'true' # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = test_kit_metadata[:repo] + # spec.metadata['source_code_uri'] = test_kit_metadata['repo'] spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], From 0bf87f14d996b6e5d0407a1fcc7db55587bbd06e Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 08:14:07 -0500 Subject: [PATCH 11/18] Revert "wip" This reverts commit c0c88f73d4ec7305fe3b4537651037f00a6ad780. --- .../apps/cli/templates/%library_name%.gemspec.tt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index 7b554d6a2..bbbd000e6 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,16 +1,16 @@ require 'yaml' -test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml')) +test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml') Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = test_kit_metadata['version'] - spec.authors = test_kit_metadata['authors'] + spec.version = test_kit_metadata[:version] + spec.authors = test_kit_metadata[:authors] # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = test_kit_metadata['title'] - spec.description = test_kit_metadata['description'] - # spec.homepage = test_kit_metadata['repo'] + spec.summary = test_kit_metadata[:title] + spec.description = test_kit_metadata[:description] + # spec.homepage = test_kit_metadata[:repo] spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' @@ -18,9 +18,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rspec', '~> 3.10' spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') - spec.metadata['inferno_test_kit'] = 'true' # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = test_kit_metadata['repo'] + # spec.metadata['source_code_uri'] = test_kit_metadata[:repo] spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], From a95b61b627b620f585a4d4b79e0a76fc28e48f25 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 08:14:10 -0500 Subject: [PATCH 12/18] Revert "add test_kit method to suites" This reverts commit 8442bf88e72006f40704d85f634cea4dba952515. --- lib/inferno/entities/test_suite.rb | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/inferno/entities/test_suite.rb b/lib/inferno/entities/test_suite.rb index 2849d3fe8..2fe747869 100644 --- a/lib/inferno/entities/test_suite.rb +++ b/lib/inferno/entities/test_suite.rb @@ -186,28 +186,6 @@ def suite_summary(suite_summary = nil) @suite_summary = format_markdown(suite_summary) end - - def test_kit - @test_kit ||= - begin - suite_path = Object.const_source_location(name).first - suite_directory = File.dirname(suite_path) - - test_kit_gems = - Bundler - .definition - .specs - .select { |spec| spec.metadata.fetch('inferno_test_kit', 'false').casecmp? 'true' } - - test_kit_gem = test_kit_gems.find { |gem| suite_directory.start_with? gem.full_gem_path } - - test_kit_metadata_path = File.join(test_kit_gem, 'lib', test_kit_gem.name, 'test_kit_metadata.yml') - - test_kit_metadata = YAML.safe_load_file(test_kit_metadata_path) - - Repositories::TestKits.find(test_kit_metadata[:id]) - end - end end end end From bbf5bca4a3c621b322e4a6a7ae73f7e933dd8a7c Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 08:14:12 -0500 Subject: [PATCH 13/18] Revert "WIP move test kit metadata to yaml file" This reverts commit b06fcbc4f575aeacfb0202f80c51df77882a275b. --- .../cli/templates/%library_name%.gemspec.tt | 17 +++++++---------- .../cli/templates/lib/%library_name%.rb.tt | 1 + .../lib/%library_name%/metadata.rb.tt | 18 ++++++++++++++++++ .../lib/%library_name%/test_kit_metadata.yml | 16 ---------------- lib/inferno/config/boot/suites.rb | 3 ++- lib/inferno/config/boot/test_kits.rb | 17 ----------------- lib/inferno/entities/test_kit.rb | 1 - 7 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt delete mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml delete mode 100644 lib/inferno/config/boot/test_kits.rb diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index bbbd000e6..e857a74cc 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,16 +1,14 @@ -require 'yaml' - -test_kit_metadata = YAML.safe_load_file(File.join('lib', '<%= library_name %>', 'test_kit_metadata.yml') +require_relative 'lib/<%= library_name %>/metadata' Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = test_kit_metadata[:version] - spec.authors = test_kit_metadata[:authors] + spec.version = <%= module_name %>::Metadata.version + spec.authors = <%= module_name %>::Metadata.authors # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = test_kit_metadata[:title] - spec.description = test_kit_metadata[:description] - # spec.homepage = test_kit_metadata[:repo] + spec.summary = <%= module_name %>::Metadata.title + spec.description = <%= module_name %>::Metadata.description + # spec.homepage = <%= module_name %>::Metadata.repo spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' @@ -19,11 +17,10 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = test_kit_metadata[:repo] + # spec.metadata['source_code_uri'] = <%= module_name %>::Metadata.repo spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], - Dir['lib/**/*.yml'], 'LICENSE' ].flatten diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index 70ba5c046..6eb29b35b 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -1,3 +1,4 @@ +require_relative '<%= library_name %>/metadata' require_relative '<%= library_name %>/patient_group' module <%= module_name %> diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt new file mode 100644 index 000000000..c63af4fc9 --- /dev/null +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt @@ -0,0 +1,18 @@ +require 'inferno/entities/test_kit' + +module <%= module_name %> + class Metadata < Inferno::TestKit + id :<%= test_kit_id %> + title '<%= title_name %>' + description <<~DESCRIPTION + This is a big markdown description of the test kit. + DESCRIPTION + suite_ids [:<%= test_suite_id %>] + # tags ['SMART App Launch', 'US Core'] + # last_updated '2024-03-07' + version '0.0.1' + maturity 'Low' + authors <%= authors %> + # repo 'https://github.com/inferno-framework/us-core-test-kit' + end +end diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml b/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml deleted file mode 100644 index 6c41f95e7..000000000 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/test_kit_metadata.yml +++ /dev/null @@ -1,16 +0,0 @@ -id: <%= test_kit_id %> -title: <%= title_name %> -description: |- - This is a big markdown description of the test kit which - can span multiple lines -suite_ids: - - <%= test_suite_id %> -# tags: -# - SMART App Launch -# - US Core -# last_updated: '2024-03-07' -version: 0.0.1 -maturity: Low -authors: <% authors.each do |author|%> - - <%= author %> -<% end %># repo: 'https://github.com/inferno-framework/us-core-test-kit' diff --git a/lib/inferno/config/boot/suites.rb b/lib/inferno/config/boot/suites.rb index 2c73df376..58eaa257d 100644 --- a/lib/inferno/config/boot/suites.rb +++ b/lib/inferno/config/boot/suites.rb @@ -24,7 +24,8 @@ in_memory_entities_trace = TracePoint.trace(:end) do |trace| if trace.self < Inferno::Entities::Test || trace.self < Inferno::Entities::TestGroup || - trace.self < Inferno::Entities::TestSuite + trace.self < Inferno::Entities::TestSuite || + trace.self < Inferno::Entities::TestKit trace.self.add_self_to_repository end end diff --git a/lib/inferno/config/boot/test_kits.rb b/lib/inferno/config/boot/test_kits.rb deleted file mode 100644 index 625780aa9..000000000 --- a/lib/inferno/config/boot/test_kits.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'yaml' - -Inferno::Application.register_provider(:test_kits) do - prepare do - test_kit_gems = - Bundler - .definition - .specs - .select { |spec| spec.metadata.fetch('inferno_test_kit', 'false').casecmp? 'true' } - - test_kit_gems.each do |gem| - test_kit_metadata_path = File.join(gem.full_gem_path, 'lib', gem.name, 'test_kit_metadata.yml') - test_kit_metadata = YAML.safe_load_file(test_kit_metadata_path) - Inferno::Entities::TestKit.new(test_kit_metadata).add_self_to_repository - end - end -end diff --git a/lib/inferno/entities/test_kit.rb b/lib/inferno/entities/test_kit.rb index 49e4b7b95..80fcad415 100644 --- a/lib/inferno/entities/test_kit.rb +++ b/lib/inferno/entities/test_kit.rb @@ -5,7 +5,6 @@ module Inferno module Entities # @example # - # TODO: update this # module USCoreTestKit # class Metadata < Inferno::Entities::TestKit # id :us_core From f5d0a7a52fe4aac1d40a7a019d6bf07963a95493 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 08:31:47 -0500 Subject: [PATCH 14/18] add version.rb to template --- .../apps/cli/templates/%library_name%.gemspec.tt | 16 +++++++++------- .../templates/lib/%library_name%/metadata.rb.tt | 6 +++--- .../templates/lib/%library_name%/version.rb.tt | 3 +++ 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt diff --git a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt index e857a74cc..cfa1f042c 100644 --- a/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +++ b/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt @@ -1,14 +1,16 @@ -require_relative 'lib/<%= library_name %>/metadata' +require_relative 'lib/<%= library_name %>/version' Gem::Specification.new do |spec| spec.name = '<%= library_name %>' - spec.version = <%= module_name %>::Metadata.version - spec.authors = <%= module_name %>::Metadata.authors + spec.version = <%= module_name %>::VERSION + spec.authors = <%= authors %> # spec.email = ['TODO'] spec.date = Time.now.utc.strftime('%Y-%m-%d') - spec.summary = <%= module_name %>::Metadata.title - spec.description = <%= module_name %>::Metadata.description - # spec.homepage = <%= module_name %>::Metadata.repo + spec.summary = '<%= title_name %>' + # spec.description = <<~DESCRIPTION + # This is a big markdown description of the test kit. + # DESCRIPTION + # spec.homepage = 'TODO' spec.license = 'Apache-2.0' spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>' spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' @@ -17,7 +19,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'webmock', '~> 3.11' spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2') # spec.metadata['homepage_uri'] = spec.homepage - # spec.metadata['source_code_uri'] = <%= module_name %>::Metadata.repo + # spec.metadata['source_code_uri'] = 'TODO' spec.files = [ Dir['lib/**/*.rb'], Dir['lib/**/*.json'], diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt index c63af4fc9..1717ff4b3 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt @@ -1,4 +1,4 @@ -require 'inferno/entities/test_kit' +require_relative 'version' module <%= module_name %> class Metadata < Inferno::TestKit @@ -10,9 +10,9 @@ module <%= module_name %> suite_ids [:<%= test_suite_id %>] # tags ['SMART App Launch', 'US Core'] # last_updated '2024-03-07' - version '0.0.1' + version VERSION maturity 'Low' authors <%= authors %> - # repo 'https://github.com/inferno-framework/us-core-test-kit' + # repo 'TODO' end end diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt new file mode 100644 index 000000000..eccd13587 --- /dev/null +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt @@ -0,0 +1,3 @@ +module <%= module_name %> + VERSION = '0.0.1'.freeze +end From e8619c7ca59daa1bcd09b54f3828b6f6e77562b8 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 10:17:31 -0500 Subject: [PATCH 15/18] add test kit integration to suites --- .../cli/templates/lib/%library_name%.rb.tt | 1 - lib/inferno/entities/test_suite.rb | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index 6eb29b35b..ba320ce3e 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -5,7 +5,6 @@ module <%= module_name %> class Suite < Inferno::TestSuite id :<%= test_suite_id %> title '<%= title_name %> Test Suite' - version Metadata.version description '<%= human_name %> test suite.' # These inputs will be available to all tests in this suite diff --git a/lib/inferno/entities/test_suite.rb b/lib/inferno/entities/test_suite.rb index 2fe747869..4d6b28bdf 100644 --- a/lib/inferno/entities/test_suite.rb +++ b/lib/inferno/entities/test_suite.rb @@ -84,15 +84,16 @@ def reference_hash } end - # Set/get the version of this test suite. + # Set/get the version of this test suite. Defaults to the TestKit + # version. # # @param version [String] # # @return [String, nil] def version(version = nil) - return @version if version.nil? + @version = version if version.present? - @version = version + @version || test_kit&.version end # @private @@ -186,6 +187,25 @@ def suite_summary(suite_summary = nil) @suite_summary = format_markdown(suite_summary) end + + # Get the TestKit this suite belongs to + # + # @return [Inferno::Entities::TestKit] + def test_kit + return @test_kit if @test_kit + + module_name = name + + while module_name.present? && @test_kit.nil? + module_name = module_name.deconstantize + + next unless const_defined?("#{module_name}::Metadata") + + @test_kit = const_get("#{module_name}::Metadata") + end + + @test_kit + end end end end From e63032104c06e6fe4f26d063eaf2d79e1fb78260 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Thu, 21 Nov 2024 10:17:48 -0500 Subject: [PATCH 16/18] add specs for test kit behavior in suites --- spec/inferno/entities/test_suite_spec.rb | 69 +++++++++++++++++++----- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/spec/inferno/entities/test_suite_spec.rb b/spec/inferno/entities/test_suite_spec.rb index 80d0efd22..28f61dbd9 100644 --- a/spec/inferno/entities/test_suite_spec.rb +++ b/spec/inferno/entities/test_suite_spec.rb @@ -1,3 +1,26 @@ +module NoTestKit + class NoTestKitSuite < Inferno::Entities::TestSuite + id :no_test_kit + end +end + +module NestedTestKit + class Metadata < Inferno::Entities::TestKit + id :nested + version 'VERSION' + end + + class TopLevelSuite < Inferno::Entities::TestSuite + id :top_level + end + + module SubModule + class NestedSuite < Inferno::Entities::TestSuite + id :nested + end + end +end + RSpec.describe Inferno::Entities::TestSuite do let!(:suite_class) { Class.new(described_class) } let(:suite_id) { 'basic' } @@ -93,9 +116,17 @@ suite_class end - specify 'it gets/sets the version' do + it 'gets/sets the version' do expect(test_suite.version).to eq('VERSION') end + + it 'defaults to the test kit version' do + expect(NestedTestKit::TopLevelSuite.version).to eq('VERSION') + end + + it 'returns nil if no test kit or version are defined' do + expect(NoTestKit::NoTestKitSuite.version).to be_nil + end end describe '.check_configuration' do @@ -170,11 +201,11 @@ ] end - specify 'it returns an empty array if no links are set' do + it 'returns an empty array if no links are set' do expect(suite_class.links).to eq([]) end - specify 'it can set and retrieve a list of http links for display' do + it 'can set and retrieve a list of http links for display' do suite_class.links links link = suite_class.links.first expect(link[:label]).to eq('One') @@ -184,7 +215,7 @@ end describe '.add_link' do - specify 'it adds a custom link to the list' do + it 'adds a custom link to the list' do suite_class.add_link('custom_type', 'One', 'http://one.com') link = suite_class.links.first expect(link[:type]).to eq('custom_type') @@ -194,7 +225,7 @@ end describe '.source_code_url' do - specify 'it adds a source code link to the list' do + it 'adds a source code link to the list' do suite_class.source_code_url('http://github.com/source_code') link = suite_class.links.first expect(link[:type]).to eq('source_code') @@ -202,7 +233,7 @@ expect(link[:url]).to eq('http://github.com/source_code') end - specify 'it allows overriding the label for source code links' do + it 'allows overriding the label for source code links' do suite_class.source_code_url('http://github.com/source_code', label: 'My Source') link = suite_class.links.first expect(link[:label]).to eq('My Source') @@ -210,7 +241,7 @@ end describe '.ig_url' do - specify 'it adds an implementation guide link to the list' do + it 'adds an implementation guide link to the list' do suite_class.ig_url('http://ig.example.com') link = suite_class.links.first expect(link[:type]).to eq('ig') @@ -218,7 +249,7 @@ expect(link[:url]).to eq('http://ig.example.com') end - specify 'it allows overriding the label for IG links' do + it 'allows overriding the label for IG links' do suite_class.ig_url('http://ig.example.com', label: 'My IG') link = suite_class.links.first expect(link[:label]).to eq('My IG') @@ -226,7 +257,7 @@ end describe '.download_url' do - specify 'it adds a download link to the list' do + it 'adds a download link to the list' do suite_class.download_url('http://example.com/download') link = suite_class.links.first expect(link[:type]).to eq('download') @@ -234,7 +265,7 @@ expect(link[:url]).to eq('http://example.com/download') end - specify 'it allows overriding the label for download links' do + it 'allows overriding the label for download links' do suite_class.download_url('http://example.com/download', label: 'Get Latest Version') link = suite_class.links.first expect(link[:label]).to eq('Get Latest Version') @@ -242,7 +273,7 @@ end describe '.report_issue_url' do - specify 'it adds a report issue link to the list' do + it 'adds a report issue link to the list' do suite_class.report_issue_url('http://example.com/report') link = suite_class.links.first expect(link[:type]).to eq('report_issue') @@ -250,10 +281,24 @@ expect(link[:url]).to eq('http://example.com/report') end - specify 'it allows overriding the label for report issue links' do + it 'allows overriding the label for report issue links' do suite_class.report_issue_url('http://example.com/report', label: 'Report Problem') link = suite_class.links.first expect(link[:label]).to eq('Report Problem') end end + + describe '.test_kit' do + it 'returns nil if no test kit is defined' do + expect(NoTestKit::NoTestKitSuite.test_kit).to be_nil + end + + it 'returns a test kit defined in the same module as the suite' do + expect(NestedTestKit::TopLevelSuite.test_kit).to eq(NestedTestKit::Metadata) + end + + it 'returns a test kit defined in a higher-level module' do + expect(NestedTestKit::SubModule::NestedSuite.test_kit).to eq(NestedTestKit::Metadata) + end + end end From ab89a95dc23b29e62210cb413ce911865db54690 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Tue, 3 Dec 2024 10:15:53 -0500 Subject: [PATCH 17/18] use 0.0.0 for initial version --- lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt index eccd13587..056069ca0 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/version.rb.tt @@ -1,3 +1,3 @@ module <%= module_name %> - VERSION = '0.0.1'.freeze + VERSION = '0.0.0'.freeze end From cd5e7a171e4c1976ca30628175207b663297b918 Mon Sep 17 00:00:00 2001 From: Stephen MacVicar Date: Tue, 3 Dec 2024 13:22:45 -0500 Subject: [PATCH 18/18] move suite to a separate file --- .../cli/templates/lib/%library_name%.rb.tt | 60 +------------------ .../templates/lib/%library_name%/suite.rb.tt | 59 ++++++++++++++++++ 2 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt index ba320ce3e..90b802e92 100644 --- a/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt +++ b/lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt @@ -1,59 +1 @@ -require_relative '<%= library_name %>/metadata' -require_relative '<%= library_name %>/patient_group' - -module <%= module_name %> - class Suite < Inferno::TestSuite - id :<%= test_suite_id %> - title '<%= title_name %> Test Suite' - description '<%= human_name %> test suite.' - - # These inputs will be available to all tests in this suite - input :url, - title: 'FHIR Server Base Url' - - input :credentials, - title: 'OAuth Credentials', - type: :oauth_credentials, - optional: true - - # All FHIR requests in this suite will use this FHIR client - fhir_client do - url :url - oauth_credentials :credentials - end - - # All FHIR validation requests will use this FHIR validator - fhir_resource_validator do - # igs 'identifier#version' # Use this method for published IGs/versions - # igs 'igs/filename.tgz' # Use this otherwise - - exclude_message do |message| - message.message.match?(/\A\S+: \S+: URL value '.*' does not resolve/) - end - end - - # Tests and TestGroups can be defined inline - group do - id :capability_statement - title 'Capability Statement' - description 'Verify that the server has a CapabilityStatement' - - test do - id :capability_statement_read - title 'Read CapabilityStatement' - description 'Read CapabilityStatement from /metadata endpoint' - - run do - fhir_get_capability_statement - - assert_response_status(200) - assert_resource_type(:capability_statement) - end - end - end - - # Tests and TestGroups can be written in separate files and then included - # using their id - group from: :patient_group - end -end +require_relative '<%= library_name %>/suite' diff --git a/lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt b/lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt new file mode 100644 index 000000000..a2f3fec08 --- /dev/null +++ b/lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt @@ -0,0 +1,59 @@ +require_relative 'metadata' +require_relative 'patient_group' + +module <%= module_name %> + class Suite < Inferno::TestSuite + id :<%= test_suite_id %> + title '<%= title_name %> Test Suite' + description '<%= human_name %> test suite.' + + # These inputs will be available to all tests in this suite + input :url, + title: 'FHIR Server Base Url' + + input :credentials, + title: 'OAuth Credentials', + type: :oauth_credentials, + optional: true + + # All FHIR requests in this suite will use this FHIR client + fhir_client do + url :url + oauth_credentials :credentials + end + + # All FHIR validation requests will use this FHIR validator + fhir_resource_validator do + # igs 'identifier#version' # Use this method for published IGs/versions + # igs 'igs/filename.tgz' # Use this otherwise + + exclude_message do |message| + message.message.match?(/\A\S+: \S+: URL value '.*' does not resolve/) + end + end + + # Tests and TestGroups can be defined inline + group do + id :capability_statement + title 'Capability Statement' + description 'Verify that the server has a CapabilityStatement' + + test do + id :capability_statement_read + title 'Read CapabilityStatement' + description 'Read CapabilityStatement from /metadata endpoint' + + run do + fhir_get_capability_statement + + assert_response_status(200) + assert_resource_type(:capability_statement) + end + end + end + + # Tests and TestGroups can be written in separate files and then included + # using their id + group from: :patient_group + end +end \ No newline at end of file