forked from fhir-crucible/fhir_client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98e9cda
commit e251697
Showing
2 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require_relative '../../test_helper' | ||
|
||
class ClientInterfaceCreateTest < Test::Unit::TestCase | ||
def client | ||
@client ||= FHIR::Client.new('create-test') | ||
end | ||
|
||
def test_create_response_properly_parsed_xml | ||
patient = FHIR::Patient.new({'gender'=>'female', 'active'=>true, 'deceasedBoolean'=>false}) | ||
outcome = FHIR::OperationOutcome.new({'issue'=>[{'code'=>'informational', 'severity'=>'information', 'diagnostics'=>'Successfully created "Patient/foo" in 0 ms'}]}) | ||
|
||
stub_request(:post, /create-test/).to_return(body: outcome.to_xml, headers: {'Content-Type'=>'application/fhir+xml', 'Content-Location'=>'Patient/foo/_history/0'}) | ||
reply = client.create(patient) | ||
assert reply.resource.is_a?(FHIR::OperationOutcome) | ||
assert reply.resource_class == FHIR::Patient | ||
assert reply.id == 'foo' | ||
end | ||
|
||
def test_create_response_properly_parsed_json | ||
patient = FHIR::Patient.new({'gender'=>'female', 'active'=>true, 'deceasedBoolean'=>false}) | ||
outcome = FHIR::OperationOutcome.new({'issue'=>[{'code'=>'informational', 'severity'=>'information', 'diagnostics'=>'Successfully created "Patient/foo" in 0 ms'}]}) | ||
|
||
stub_request(:post, /create-test/).to_return(body: outcome.to_json, headers: {'Content-Type'=>'application/fhir+json', 'Content-Location'=>'Patient/foo/_history/0'}) | ||
reply = client.create(patient) | ||
assert reply.resource.is_a?(FHIR::OperationOutcome) | ||
assert reply.resource_class == FHIR::Patient | ||
assert reply.id == 'foo' | ||
end | ||
|
||
def test_create_response_blank | ||
patient = FHIR::Patient.new({'gender'=>'female', 'active'=>true, 'deceasedBoolean'=>false}) | ||
|
||
stub_request(:post, /create-test/).to_return(headers: {'Content-Location'=>'Patient/foo/_history/0'}) | ||
reply = client.create(patient) | ||
assert reply.resource.is_a?(FHIR::Patient) | ||
assert reply.resource_class == FHIR::Patient | ||
assert reply.id == 'foo' | ||
end | ||
|
||
def test_read | ||
patient = FHIR::Patient.new({'gender'=>'female', 'active'=>true, 'deceasedBoolean'=>false}) | ||
|
||
stub_request(:get, /create-test/).to_return(body: patient.to_json, headers: {'Content-Type'=>'application/fhir+json', 'Content-Location'=>'Patient/foo/_history/0'}) | ||
reply = client.read(FHIR::Patient,'foo') | ||
assert reply.resource.is_a?(FHIR::Patient) | ||
assert reply.resource_class == FHIR::Patient | ||
assert reply.id == 'foo' | ||
end | ||
|
||
end |