forked from fhir-crucible/fhir_client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_test.rb
54 lines (42 loc) · 1.4 KB
/
model_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require_relative '../test_helper'
class TestUnitCustomException < ClientException ; end
class ModelTest < Test::Unit::TestCase
def test_default_instance_exception
stub_request(:post, /create/).to_return(status: 403, body: "")
client = FHIR::Client.new('create')
client.default_json
FHIR::Model.client = client
assert_raise ClientException do
FHIR::Patient.new({'id':'foo'}).create
end
end
def test_custom_instance_exception
stub_request(:post, /create/).to_return(status: 403, body: "")
client = FHIR::Client.new('create')
client.default_json
client.exception_class = TestUnitCustomException
FHIR::Model.client = client
assert_raise TestUnitCustomException do
FHIR::Patient.new({'id':'foo'}).create
end
end
def test_default_class_exception
stub_request(:post, /create/).to_return(status: 403, body: "")
client = FHIR::Client.new('create')
client.default_json
FHIR::Model.client = client
assert_raise ClientException do
FHIR::Patient.create({'id':'foo'})
end
end
def test_custom_class_exception
stub_request(:post, /create/).to_return(status: 403, body: "")
client = FHIR::Client.new('create')
client.default_json
client.exception_class = TestUnitCustomException
FHIR::Model.client = client
assert_raise TestUnitCustomException do
FHIR::Patient.create({'id':'foo'})
end
end
end