Class: ODDB::TestLppvPlugin

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



33
34
35
36
# File 'test/test_plugin/lppv.rb', line 33

def setup
  @app = FlexMock.new
  @plugin = LppvPlugin.new(@app)
end

- (Object) test_update_package__no_price



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'test/test_plugin/lppv.rb', line 119

def test_update_package__no_price
  data = {
    '1234567' => '9.90',
    '7654321' => '9.90'
  }
  package = FlexMock.new
  package2 = FlexMock.new
  package.should_receive(:pointer).and_return { 'package-pointer' }
  package.should_receive(:name).and_return { 'Namenda' }
  package.should_receive(:price_public).and_return { Util::Money.new(1000) }
  package.should_receive(:pharmacode).and_return { '1234567' }
  package.should_receive(:sl_entry).and_return { }
  @app.should_receive(:update, 1).and_return { |pointer, hash|
    assert_equal('package-pointer', pointer)
    expected = { :price_public => "9.90", :lppv => true}
    assert_equal(expected, hash)
  }
  @plugin.update_package(package, data)
  package2.should_receive(:pointer).and_return { 'package-pointer' }
  package2.should_receive(:name).and_return { 'Bla' }
  package2.should_receive(:price_public).and_return {900 }
  package2.should_receive(:pharmacode).and_return { '7654321' }
  package2.should_receive(:sl_entry).and_return { }
  @app.should_receive(:update, 2).and_return { |pointer, hash|
    assert_equal('package-pointer', pointer)
    expected = { :price_public => "9.90",:lppv => true}
    assert_equal(expected, hash)
  }
  @plugin.update_package(package2, data)
  update = @plugin.updated_packages.first
  assert_instance_of(LppvPlugin::PriceUpdate, update)
  @app.flexmock_verify
end

- (Object) test_update_package__price_down



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'test/test_plugin/lppv.rb', line 58

def test_update_package__price_down
  data = {
      '1234567' => '9.90',
      '7654321' => '5.55',
  }
  package = FlexMock.new
  package.should_receive(:pointer).and_return{ 'package-pointer' }
  package.should_receive(:iksnr).and_return { }
  package.should_receive(:name).and_return { 'Neuer Name' }
  package.should_receive(:price_public).and_return { Util::Money.new(1000) }
  package.should_receive(:pharmacode).and_return { '1234567' }
  package.should_receive(:sl_entry).and_return { }
  @app.should_receive(:update, 1).and_return { |pointer, hash|
  assert_equal('package-pointer', pointer)
  expected = { :price_public => "9.90", :lppv => true}
  assert_equal(expected, hash)
  }
  @plugin.update_package(package, data)
  update = @plugin.updated_packages.first
  assert_instance_of(LppvPlugin::PriceUpdate, update)
  assert(update.down?)
  @app.flexmock_verify
end

- (Object) test_update_package__price_same__lppv



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'test/test_plugin/lppv.rb', line 102

def test_update_package__price_same__lppv
  data = {
    '1234567' => '9.90',
  }  
  package = FlexMock.new
  package.should_receive(:pointer).and_return { 'package-pointer' }
  package.should_receive(:name).and_return { 'Noch a Name' }
  package.should_receive(:iksnr).and_return { }
  package.should_receive(:price_public).and_return { Util::Money.new(9.90) }
  package.should_receive(:pharmacode).and_return { '1234567' }
  package.should_receive(:sl_entry).and_return { }
  package.should_receive(:lppv).and_return { true }
  @app.should_receive(:update, 0).and_return { }
  @plugin.update_package(package, data)
  assert_equal([], @plugin.updated_packages)
  @app.flexmock_verify
end

- (Object) test_update_package__price_same__no_lppv



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'test/test_plugin/lppv.rb', line 81

def test_update_package__price_same__no_lppv
  data = {
    '1234567' =>  '9.90',    
  }
  package = FlexMock.new
  package.should_receive(:pointer).and_return { 'package-pointer' }
  package.should_receive(:name).and_return { 'Der Name' }
  package.should_receive(:price_public).and_return { Util::Money.new(9.90) }
  package.should_receive(:pharmacode).and_return { '1234567' }
  package.should_receive(:sl_entry).and_return {  }
  package.should_receive(:lppv).and_return {  }
  @app.should_receive(:update, 1).and_return { |pointer, hash|
    assert_equal('package-pointer', pointer)
    expected = { :price_public  => "9.90", :lppv => true}
    assert_equal(expected, hash)
  }
  @plugin.update_package(package, data)
  update = @plugin.updated_packages.first
  assert_instance_of(LppvPlugin::PriceUpdate, update)
  @app.flexmock_verify
end

- (Object) test_update_package__price_up



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'test/test_plugin/lppv.rb', line 37

def test_update_package__price_up
  data = {
    '1234567' =>  '9.90',    
  }
  package = FlexMock.new
  package.should_receive(:pointer).and_return { 'package-pointer' }
  package.should_receive(:name).and_return { 'Der Name' }
  package.should_receive(:price_public).and_return { Util::Money.new(2.50) }
  package.should_receive(:pharmacode).and_return { '1234567' }
  package.should_receive(:sl_entry).and_return {  }
  @app.should_receive(:update, 1).and_return { |pointer, hash|
    assert_equal('package-pointer', pointer)
    expected = { :price_public  => "9.90", :lppv => true}
    assert_equal(expected, hash)
  }
  @plugin.update_package(package, data)
  update = @plugin.updated_packages.first
  assert_instance_of(LppvPlugin::PriceUpdate, update)
  assert(update.up?)
  @app.flexmock_verify
end