generated from inferno-framework/inferno-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FI-1888: Update profile support test (#103)
* remove profile checks and add optional resource check to profile support test * add specs for profile support test
- Loading branch information
1 parent
a217e27
commit b8df232
Showing
5 changed files
with
180 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
require_relative '../../lib/us_core_test_kit/custom_groups/capability_statement/profile_support_test' | ||
|
||
RSpec.describe USCoreTestKit::ProfileSupportTest do | ||
def run(runnable, inputs = {}) | ||
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) | ||
test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) | ||
inputs.each do |name, value| | ||
session_data_repo.save( | ||
test_session_id: test_session.id, | ||
name: name, | ||
value: value, | ||
type: runnable.config.input_type(name) || 'text' | ||
) | ||
end | ||
Inferno::TestRunner.new(test_session: test_session, test_run: test_run).run(runnable) | ||
end | ||
|
||
let(:session_data_repo) { Inferno::Repositories::SessionData.new } | ||
let(:test_session) { repo_create(:test_session, test_suite_id: suite.id) } | ||
let(:suite) { Inferno::Repositories::TestSuites.new.find('us_core_v311') } | ||
let(:test) { described_class } | ||
let(:url) { 'http://example.com/fhir' } | ||
|
||
context 'with no required resources' do | ||
before do | ||
allow_any_instance_of(test).to receive(:config).and_return( | ||
OpenStruct.new( | ||
options: { | ||
us_core_resources: ['Patient', 'Condition', 'Observation'] | ||
} | ||
) | ||
) | ||
end | ||
|
||
it 'fails if Patient is not supported' do | ||
response_body = | ||
FHIR::CapabilityStatement.new( | ||
rest: [ | ||
{ | ||
resource: [ | ||
{ | ||
type: 'Condition' | ||
} | ||
] | ||
} | ||
] | ||
).to_json | ||
repo_create(:request, response_body:, name: 'capability_statement', test_session_id: test_session.id) | ||
|
||
result = run(test, url:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to eq('US Core Patient profile not supported') | ||
end | ||
|
||
it 'fails if only the Patient resource is supported' do | ||
response_body = | ||
FHIR::CapabilityStatement.new( | ||
rest: [ | ||
{ | ||
resource: [ | ||
{ | ||
type: 'Patient' | ||
} | ||
] | ||
} | ||
] | ||
).to_json | ||
repo_create(:request, response_body:, name: 'capability_statement', test_session_id: test_session.id) | ||
|
||
result = run(test, url:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to eq('No US Core resources other than Patient are supported') | ||
end | ||
|
||
it 'passes if Patient and one other resource are supported' do | ||
response_body = | ||
FHIR::CapabilityStatement.new( | ||
rest: [ | ||
{ | ||
resource: [ | ||
{ | ||
type: 'Patient' | ||
}, | ||
{ | ||
type: 'Observation' | ||
} | ||
] | ||
} | ||
] | ||
).to_json | ||
repo_create(:request, response_body:, name: 'capability_statement', test_session_id: test_session.id) | ||
|
||
result = run(test, url:) | ||
|
||
expect(result.result).to eq('pass') | ||
end | ||
end | ||
|
||
context 'with required resources' do | ||
before do | ||
allow_any_instance_of(test).to receive(:config).and_return( | ||
OpenStruct.new( | ||
options: { | ||
us_core_resources: ['Patient', 'Condition', 'Observation'], | ||
required_resources: ['Patient', 'Condition', 'Observation'] | ||
} | ||
) | ||
) | ||
end | ||
|
||
it 'fails if not all required resources are supported' do | ||
response_body = | ||
FHIR::CapabilityStatement.new( | ||
rest: [ | ||
{ | ||
resource: [ | ||
{ | ||
type: 'Patient' | ||
}, | ||
{ | ||
type: 'Observation' | ||
} | ||
] | ||
} | ||
] | ||
).to_json | ||
repo_create(:request, response_body:, name: 'capability_statement', test_session_id: test_session.id) | ||
|
||
result = run(test, url:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to include('Condition') | ||
end | ||
|
||
it 'passes if not required resources are supported' do | ||
response_body = | ||
FHIR::CapabilityStatement.new( | ||
rest: [ | ||
{ | ||
resource: [ | ||
{ | ||
type: 'Patient' | ||
}, | ||
{ | ||
type: 'Observation' | ||
}, | ||
{ | ||
type: 'Condition' | ||
} | ||
] | ||
} | ||
] | ||
).to_json | ||
repo_create(:request, response_body:, name: 'capability_statement', test_session_id: test_session.id) | ||
|
||
result = run(test, url:) | ||
|
||
expect(result.result).to eq('pass') | ||
end | ||
end | ||
end |