Class: ODDB::MedData::HospitalPluginTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_plugin/hospitals.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



15
16
17
18
19
20
21
22
# File 'test/test_plugin/hospitals.rb', line 15

def setup 
  @app = Mock.new("app")
  @plugin = ODDB::HospitalPlugin.new(@app)
  @meddata = Mock.new('meddata')
  @meddata_server = FlexMock.new
  @meddata_server.should_receive(:session).and_return { yield @meddata }
  @plugin.meddata_server = @meddata_server
end

- (Object) teardown



23
24
25
26
# File 'test/test_plugin/hospitals.rb', line 23

def teardown
  @meddata.__verify
  @app.__verify
end

- (Object) test_hospital_details__1



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'test/test_plugin/hospitals.rb', line 60

def test_hospital_details__1
  template = {
    :ean13        =>  [1,0],
    :name         =>  [1,2],
    :business_unit => [1,3],
    :address      => [1,4],
    :plz          => [1,5],
    :location     =>  [2,5],
    :phone        =>  [1,6],
    :fax          => [2,6],
    :canton       => [3,5],
    :narcotics      => [1,10],
  }
  result = Mock.new('result_mock')
  result.__next(:ctl) {}
  @meddata.__next(:detail) { |result, templ| 
    assert_equal(template, templ)
    {
      :name  => 'Hospital',
    }
  }
  retval = @plugin.hospital_details(@meddata, result)
  expected = {
    :name => 'Hospital',
    #:business_area => :hospital,
  }
  assert_equal(expected, retval)
end

- (Object) test_update_hospital__1



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'test/test_plugin/hospitals.rb', line 27

def test_update_hospital__1
  values = {
    :ean13  => '7680123456789'
  }
  @app.__next(:hospital) { |ean|
    assert_equal('7680123456789', ean)
    nil
  }
  @app.__next(:update) { |ptr, vals, orig|
    assert_equal(values, vals)
    assert_instance_of(Persistence::Pointer, ptr)
    assert_equal([:create], ptr.skeleton)
    assert_equal(:refdata, orig)
  }
  @plugin.update_hospital(values)
end

- (Object) test_update_hospital__2



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'test/test_plugin/hospitals.rb', line 43

def test_update_hospital__2
  values = {
    :ean13  => '1324657675434'
  }
  mock1 = Mock.new('hospital_mock')
  mock1.__next(:pointer) { "pointer" }
  @app.__next(:hospital) { |ean|
    assert_equal('1324657675434', ean)
    mock1
  }
  @app.__next(:update) { |ptr, vals, orig|
    assert_equal(values, vals)
    assert_equal("pointer", ptr)
    assert_equal(:refdata, orig)
  }
  @plugin.update_hospital(values)
end