Class: ODDB::TestDoctor

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
test/test_model/doctor.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



18
19
20
# File 'test/test_model/doctor.rb', line 18

def setup
  @doctor = Doctor.new
end

- (Object) teardown



21
22
23
# File 'test/test_model/doctor.rb', line 21

def teardown
  ODBA.storage = nil
end

- (Object) test_adjust_types



150
151
152
153
154
155
156
157
158
159
160
# File 'test/test_model/doctor.rb', line 150

def test_adjust_types
  data = {
    :capabilities => "Neurologie\nPsychiatrie",
    :exam         => '1985',
  }
  expected = {
    :capabilities => %w{Neurologie Psychiatrie},
    :exam         => 1985,
  }
  assert_equal expected, @doctor.adjust_types(data)
end

- (Object) test_create_address



118
119
120
121
122
123
# File 'test/test_model/doctor.rb', line 118

def test_create_address
  assert_equal([], @doctor.addresses)
  addr = @doctor.create_address(0)
  assert_instance_of(Address2, addr)
  assert_equal([addr], @doctor.addresses)
end

- (Object) test_fullname



32
33
34
35
36
# File 'test/test_model/doctor.rb', line 32

def test_fullname
  @doctor.firstname = 'FirstName'
  @doctor.name = 'LastName'
  assert_equal 'FirstName LastName', @doctor.fullname
end

- (Object) test_init



24
25
26
27
28
29
30
31
# File 'test/test_model/doctor.rb', line 24

def test_init
  pointer = flexmock 'pointer'
  pointer.should_receive(:append).and_return { |oid|
    assert_equal(@doctor.oid, oid)
  }
  @doctor.pointer = pointer
  @doctor.init(nil)
end

- (Object) test_pointer_descr



37
38
39
40
41
42
# File 'test/test_model/doctor.rb', line 37

def test_pointer_descr
  @doctor.firstname = 'FirstName'
  @doctor.name = 'LastName'
  @doctor.title = 'Dr.'
  assert_equal 'Dr. FirstName LastName', @doctor.pointer_descr
end

- (Object) test_praxis_address



51
52
53
54
55
56
57
58
59
60
# File 'test/test_model/doctor.rb', line 51

def test_praxis_address
  addr1 = flexmock "praxis_addresse1"
  addr1.should_receive(:type).and_return { 'at_praxis' }
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "work_addresse3"
  addr3.should_receive(:type).and_return { 'at_work' }
  @doctor.addresses = [addr1, addr2, addr3]
  assert_equal(addr1, @doctor.praxis_address)
end

- (Object) test_praxis_address__nil



61
62
63
64
65
66
67
68
# File 'test/test_model/doctor.rb', line 61

def test_praxis_address__nil
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "work_addresse3"
  addr3.should_receive(:type).and_return { 'at_work' }
  @doctor.addresses = [addr2, addr3]
  assert_nil(@doctor.praxis_address)
end

- (Object) test_praxis_address__not_first



69
70
71
72
73
74
75
76
77
78
# File 'test/test_model/doctor.rb', line 69

def test_praxis_address__not_first
  addr1 = flexmock "praxis_addresse1"
  addr1.should_receive(:type).and_return { 'at_praxis' }
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "work_addresse3"
  addr3.should_receive(:type).and_return { 'at_work' }
  @doctor.addresses = [addr2, addr1, addr3]
  assert_equal(addr1, @doctor.praxis_address)
end

- (Object) test_praxis_addresses



79
80
81
82
83
84
85
86
87
88
# File 'test/test_model/doctor.rb', line 79

def test_praxis_addresses
  addr1 = flexmock "praxis_addresse1"
  addr1.should_receive(:type).and_return { 'at_praxis' }
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "work_addresse3"
  addr3.should_receive(:type).and_return { 'at_praxis' }
  @doctor.addresses = [addr1, addr2, addr3]
  assert_equal([addr1, addr3], @doctor.praxis_addresses)
end

- (Object) test_record_match



43
44
45
46
47
48
49
50
# File 'test/test_model/doctor.rb', line 43

def test_record_match
  @doctor.origin_db = :origin
  @doctor.origin_id = 12345
  assert(@doctor.record_match?(:origin, 12345))
  assert(!@doctor.record_match?(:oorigin, 12345))
  assert(!@doctor.record_match?(:origin, 54321))
  assert(!@doctor.record_match?(:oorigin, 54321))
end

- (Object) test_search_terms



124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'test/test_model/doctor.rb', line 124

def test_search_terms
  @doctor.name = 'Last-Name'
  @doctor.firstname = 'First-Name'
  @doctor. = 'email@test.ch'
  @doctor.specialities = ['Neurologie']
  @doctor.ean13 = '7681123456789'
  addr = flexmock 'address'
  addr.should_receive(:search_terms).and_return ['Street', 'Location']
  @doctor.addresses.push addr
  expected = [ "Last", "LastName", "Last Name", "First", "FirstName",
               "First Name", "emailtestch", "Neurologie", "7681123456789",
               "Street", "Location" ]
  assert_equal expected, @doctor.search_terms
end

- (Object) test_search_text



138
139
140
141
142
143
144
145
146
147
148
149
# File 'test/test_model/doctor.rb', line 138

def test_search_text
  @doctor.name = 'Last-Name'
  @doctor.firstname = 'First-Name'
  @doctor. = 'email@test.ch'
  @doctor.specialities = ['Neurologie']
  @doctor.ean13 = '7681123456789'
  addr = flexmock 'address'
  addr.should_receive(:search_terms).and_return ['Street', 'Location']
  @doctor.addresses.push addr
  expected = "Last LastName Last Name First FirstName First Name emailtestch Neurologie 7681123456789 Street Location"
  assert_equal expected, @doctor.search_text
end

- (Object) test_work_addresses



89
90
91
92
93
94
95
96
97
98
99
# File 'test/test_model/doctor.rb', line 89

def test_work_addresses
  addr1 = flexmock "praxis_addresse1"
  addr1.should_receive(:type).and_return { 'at_praxis' }
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "work_addresse3"
  addr3.should_receive(:type).and_return { 'at_work' }
  @doctor.addresses = [addr1, addr2, addr3]
  expected = [addr2, addr3]
  assert_equal(expected, @doctor.work_addresses)
end

- (Object) test_work_addresses__first



107
108
109
110
111
112
113
114
115
116
117
# File 'test/test_model/doctor.rb', line 107

def test_work_addresses__first
  addr1 = flexmock "work_addresse1"
  addr1.should_receive(:type).and_return { 'at_work' }
  addr2 = flexmock "work_addresse2"
  addr2.should_receive(:type).and_return { 'at_work' }
  addr3 = flexmock "praxis_addresse3"
  addr3.should_receive(:type).and_return { 'at_praxis' }
  @doctor.addresses = [addr1, addr2, addr3]
  expected = [addr1, addr2]
  assert_equal(expected, @doctor.work_addresses)
end

- (Object) test_work_addresses__nil



100
101
102
103
104
105
106
# File 'test/test_model/doctor.rb', line 100

def test_work_addresses__nil
  addr1 = flexmock "praxis_addresse1"
  addr1.should_receive(:type).and_return { 'at_praxis' }
  @doctor.addresses = [addr1]
  expected = []
  assert_equal(expected, @doctor.work_addresses)
end