Skip to content

Commit

Permalink
Merge branch 'main' into FI-3261-markdown-descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyssaWang authored Dec 10, 2024
2 parents b72c706 + 2c6d592 commit ccdbb9c
Show file tree
Hide file tree
Showing 22 changed files with 269 additions and 101 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.5.2
* FI-3366: Fetch report date from test results by @AlyssaWang in https://github.com/inferno-framework/inferno-core/pull/567
* FI-3019: Add custom blockquote styles by @AlyssaWang in https://github.com/inferno-framework/inferno-core/pull/556
* FI-2622: Update meta tags for link unfurling by @AlyssaWang in https://github.com/inferno-framework/inferno-core/pull/553
* FI-2961 execute preset support by @Shaumik-Ashraf in https://github.com/inferno-framework/inferno-core/pull/565
* FI-3511: Fix json handling by @Jammjammjamm in https://github.com/inferno-framework/inferno-core/pull/568

## 0.5.1
* FI-3097: Maintain checkbox label colors on error by @AlyssaWang in https://github.com/inferno-framework/inferno-core/pull/537
* Fi 2962 execute outputters by @Shaumik-Ashraf in https://github.com/inferno-framework/inferno-core/pull/541
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
inferno_core (0.5.1)
inferno_core (0.5.2)
activesupport (~> 6.1.7.5)
base62-rb (= 0.3.1)
blueprinter (= 0.25.2)
Expand Down Expand Up @@ -239,7 +239,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.8)
rexml (3.3.9)
rouge (4.4.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require_relative 'empty_group'
require_relative 'external_outer_group'
require_relative 'failing_optional_group'
require_relative 'passing_optional_group'
require_relative 'json_test_endpoint'
require_relative 'mixed_optional_group'
require_relative 'empty_group'
require_relative 'passing_optional_group'

module InfrastructureTest
class Suite < Inferno::TestSuite
Expand All @@ -29,6 +30,8 @@ class Suite < Inferno::TestSuite
}
]

suite_endpoint :post, '/json_test', JSONTestEndpoint

input :suite_input
output :suite_output

Expand Down
9 changes: 9 additions & 0 deletions dev_suites/dev_infrastructure_test/json_test_endpoint.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class JSONTestEndpoint < Inferno::DSL::SuiteEndpoint
def test_run_identifier
'ABC'
end

def make_response
response.body = req.params[:json_param]
end
end
17 changes: 9 additions & 8 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GEM
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.10)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
dnsruby (1.72.0)
simpleidn (~> 0.2.1)
em-websocket (0.5.3)
Expand Down Expand Up @@ -210,24 +210,24 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.22.3)
minitest (5.25.4)
net-http (0.4.1)
uri
nokogiri (1.16.4-arm64-darwin)
nokogiri (1.16.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-darwin)
nokogiri (1.16.8-x86_64-darwin)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.7.3)
racc (1.8.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.6)
rexml (3.3.9)
rouge (3.26.0)
rubyzip (2.3.2)
safe_yaml (1.0.5)
Expand All @@ -253,10 +253,11 @@ GEM
unf_ext (0.0.9.1)
unicode-display_width (1.8.0)
uri (0.13.0)
webrick (1.8.1)
zeitwerk (2.6.13)
webrick (1.9.1)
zeitwerk (2.6.18)

PLATFORMS
arm64-darwin-21
arm64-darwin-22
x86_64-darwin-22

Expand Down
10 changes: 7 additions & 3 deletions lib/inferno/apps/cli/templates/%library_name%.gemspec.tt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
require_relative 'lib/<%= library_name %>/version'

Gem::Specification.new do |spec|
spec.name = '<%= library_name %>'
spec.version = '0.0.1'
spec.version = <%= module_name %>::VERSION
spec.authors = <%= 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.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 %>'
Expand Down
5 changes: 3 additions & 2 deletions lib/inferno/apps/cli/templates/Dockerfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

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
Expand Down
59 changes: 1 addition & 58 deletions lib/inferno/apps/cli/templates/lib/%library_name%.rb.tt
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
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'
18 changes: 18 additions & 0 deletions lib/inferno/apps/cli/templates/lib/%library_name%/metadata.rb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_relative 'version'

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 VERSION
maturity 'Low'
authors <%= authors %>
# repo 'TODO'
end
end
59 changes: 59 additions & 0 deletions lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module <%= module_name %>
VERSION = '0.0.0'.freeze
end
4 changes: 4 additions & 0 deletions lib/inferno/apps/web/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'hanami/middleware/body_parser'
require_relative 'router'

# Only required to monkey patch the JSON parser to support application/fhir+json
require 'hanami/middleware/body_parser/json_parser'
require_relative '../../ext/json_parser'

module Inferno
module Web
def self.app
Expand Down
1 change: 1 addition & 0 deletions lib/inferno/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 4 additions & 2 deletions lib/inferno/entities/test_kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,7 +156,7 @@ def add_self_to_repository

# @private
def repository
@repository ||= Inferno::Repositories::TestKits
@repository ||= Inferno::Repositories::TestKits.new
end

# @private
Expand All @@ -168,4 +168,6 @@ def copy_instance_variables
end
end
end

TestKit = Entities::TestKit
end
26 changes: 23 additions & 3 deletions lib/inferno/entities/test_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions lib/inferno/ext/json_parser.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Hanami
module Middleware
class BodyParser
class JsonParser
def self.mime_types
['application/json', 'application/vnd.api+json', 'application/fhir+json']
end
end
end
end
end
Loading

0 comments on commit ccdbb9c

Please sign in to comment.