Skip to content

Commit

Permalink
add test for conditional create
Browse files Browse the repository at this point in the history
  • Loading branch information
radamson committed Mar 21, 2019
1 parent 18f76d7 commit d182c60
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/unit/client_interface_sections/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,22 @@ def test_create_response_blank
assert !reply.is_valid? # reply isn't valid because a response should have been included
end

def test_condiitonal_create
patient = FHIR::Patient.new({'gender'=>'female', 'active'=>true, 'deceasedBoolean'=>false})


stub_request(:post, /create-test/)
.with(headers: {'Content-Type'=>'application/fhir+json;charset=utf-8',
'If-None-Exist'=>'identifier=1234'})
.to_return(status: 201,
headers: {'Location'=>'http:https://create-test/Patient/foo/_history/0',
'ETag'=>'W/"foo"',
'Last-Modified'=>Time.now.strftime("%a, %e %b %Y %T %Z")})
client.default_json
reply = client.conditional_create(patient, {'identifier': '1234'})
assert reply.resource.is_a? (FHIR::Patient)
assert reply.resource_class == FHIR::Patient
assert reply.id == 'foo'
end

end

0 comments on commit d182c60

Please sign in to comment.