Skip to content

Commit

Permalink
Addressed MR comments
Browse files Browse the repository at this point in the history
-TODO: Address the endpoint configuration for spec file
  • Loading branch information
degradification committed Dec 26, 2024
1 parent 209fa37 commit 078f816
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
module DaVinciDTRTestKit
class DTRLightEhrSupportedEndpointsGroup < Inferno::TestGroup
id :dtr_light_ehr_supported_endpoints
title 'DTR Supported Endpoints'
description %(
Demonstrate the ability to access supported endpoints
)
title 'Supported Endpoints'
description %(This test group tests system for their conformance to
the supported endpoint capabilities as defined by the DaVinci Documentation
Templates and Rules (DTR) v2.0.1 Implementation Guide Light DTR EHR
Capability Statement.
)
run_as_group

test from: :dtr_light_ehr_supported_payer_endpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
require_relative '../../urls'

module DaVinciDTRTestKit
class DtrLightEhrSupportedPayerEndpointTest < Inferno::Test
class DTRLightEhrSupportedPayerEndpointTest < Inferno::Test
include URLs
id :dtr_light_ehr_supported_payer_endpoint
title 'Client can retrieve payers from supported payer endpoint'
description %(
Inferno, will wait for a request to return the payer details from the supported endpoint.
This test verifies that the app can successfully access the supported payer endpoint via a GET request,
including an Accept header set to application/json
)
input :access_token,
description: %(
Expand Down
14 changes: 2 additions & 12 deletions lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DTRLightEHRSuite < Inferno::TestSuite
end
end

suite_endpoint :get, SUPPORTED_PAYER_PATH, MockPayer::LightEHRSupportedPayerEndpoint
suite_endpoint :get, SUPPORTED_PAYER_PATH, LightEHRSupportedPayerEndpoint

group do
title 'Authorization'
Expand Down Expand Up @@ -141,16 +141,6 @@ class DTRLightEHRSuite < Inferno::TestSuite
group from: :vision_prescription_group
end

group do
title 'DTR Light EHR Supported Endpoints'
description %(This test group tests system for their conformance to
the supported endpoint capabilities as defined by the DaVinci Documentation
Templates and Rules (DTR) v2.0.1 Implementation Guide Light DTR EHR
Capability Statement.
)

group from: :dtr_light_ehr_supported_endpoints
end
group from: :dtr_light_ehr_supported_endpoints
end
end
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
require_relative '../mock_payer'
require_relative '../../tags'

module DaVinciDTRTestKit
module MockPayer
class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint
include MockPayer

def name
'light_ehr_supported_payer_endpoint'
end

def test_run_identifier
request.headers['authorization']&.delete_prefix('Bearer ')
end
class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint
def name
'light_ehr_supported_payer_endpoint'
end

def tags
[SUPPORTED_PAYER_TAG]
end
def test_run_identifier
request.headers['authorization']&.delete_prefix('Bearer ')
end

def make_response
puts "Request method: #{request.request_method}"
if request.headers['Accept'] != 'application/json'
response.status = 406
response.headers['Content-Type'] = 'application/json'
response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json
return
end
def tags
[SUPPORTED_PAYER_TAG]
end

response.status = 200
def make_response
puts "Request method: #{request.request_method}"
if request.headers['Accept'] != 'application/json'
response.status = 406
response.headers['Content-Type'] = 'application/json'
response.body = {
payers: [
{ id: 'payer1', name: 'Payer One' },
{ id: 'payer2', name: 'Payer Two' }
]
}.to_json
response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json
return
end

def update_result
results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests]
response.status = 200
response.headers['Content-Type'] = 'application/json'
response.body = {
payers: [
{ id: 'payer1', name: 'Payer One' },
{ id: 'payer2', name: 'Payer Two' }
]
}.to_json
end

def update_result
if request.headers['Accept'] == 'application/json'
results_repo.update_result(result.id, 'pass')
else
results_repo.update_result(result.id, 'fail')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
require_relative '../request_helper'

RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedEndpointsGroup do
RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedPayerEndpointTest do
include Rack::Test::Methods
include RequestHelpers

def app
Inferno::Web.app
end

let(:group) { Inferno::Repositories::TestGroups.new.find('dtr_light_ehr_supported_payer_endpoint') }
let(:suite_id) { :dtr_light_ehr }
let(:resume_pass_url) { "/custom/#{suite_id}/resume_pass" }
let(:resume_fail_url) { "/custom/#{suite_id}/resume_fail" }
let(:supported_payer_url) { "/custom/#{suite_id}/supported_payers" }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:test_session) { repo_create(:test_session, test_suite_id: suite_id) }
let(:test_runs_repo) { Inferno::Repositories::TestRuns.new }
Expand All @@ -35,15 +37,15 @@ def run(runnable, test_session, inputs = {})

it 'passes when a request is made to the supported payers endpoint' do
header 'Accept', 'application/json'
get '/supported-payers'
get supported_payer_url

expect(last_response.status).to eq(200)
expect(last_response.content_type).to eq('application/json')
expect(JSON.parse(last_response.body)['payers']).to be_an(Array)

result = repo_create(:result, test_session_id: test_session.id)
repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil,
test_session_id: test_session.id, tags: ['supported_payers'])
test_session_id: test_session.id, tags: [SUPPORTED_PAYER_TAG])

result = run(runnable, test_session)
expect(result.result).to eq('wait')
Expand All @@ -56,7 +58,7 @@ def run(runnable, test_session, inputs = {})
end

it 'returns 406 when Accept header is missing or incorrect' do
get '/supported-payers'
get supported_payer_url

expect(last_response.status).to eq(406)
expect(JSON.parse(last_response.body)['error']).to eq('Not Acceptable')
Expand Down

0 comments on commit 078f816

Please sign in to comment.