Class: ODDB::TestPackage

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



51
52
53
54
# File 'test/test_model/package.rb', line 51

def setup
  @package = ODDB::Package.new('12')
  @package.sequence = StubPackageSequence.new
end

- (Object) test_active



59
60
61
62
63
64
65
66
67
68
69
# File 'test/test_model/package.rb', line 59

def test_active
  assert_equal(true, @package.active?)
  @package.out_of_trade = true
  assert_equal(true, @package.active?)
  @package.refdata_override = true
  assert_equal(true, @package.active?)
  @package.market_date = Date.today + 1
  assert_equal(false, @package.active?)
  @package.market_date = Date.today
  assert_equal(true, @package.active?)
end

- (Object) test_active_agents



70
71
72
73
74
# File 'test/test_model/package.rb', line 70

def test_active_agents
  @package.parts.push flexmock(:active_agents => ['act1', 'act2']),
                      flexmock(:active_agents => ['act3'])
  assert_equal %w{act1 act2 act3}, @package.active_agents
end

- (Object) test_adjust_types



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'test/test_model/package.rb', line 75

def test_adjust_types
  app = flexmock 'app'
  pointer = flexmock 'pointer'
  pointer.should_receive(:resolve).with(app).times(1).and_return 'generic-group'
  values = {
    :size           => '20 x 1,7 g',
    :descr          => nil,
    :ikscat         =>  'A',
    :generic_group  => pointer,
    :price_exfactory=>  Util::Money.new(12.34),
    :price_public   => Util::Money.new(15),
    :pretty_dose    =>  Dose.new(10, 'mg'),
    :ddd_dose       =>  [20, 'mg'],
  }
  expected = {
    :size           => '20 x 1,7 g',
    :descr          => nil,
    :ikscat         =>  'A',
    :generic_group  => 'generic-group',
    :price_exfactory=>  Util::Money.new(12.34),
    :price_public   => Util::Money.new(15),
    :pretty_dose    =>  Dose.new(10, 'mg'),
    :ddd_dose       =>  Dose.new(20, 'mg'),
  }
  assert_equal(expected, @package.adjust_types(values, app))
end

- (Object) test_barcode



101
102
103
# File 'test/test_model/package.rb', line 101

def test_barcode
  assert_equal('7680123450123', @package.barcode)
end

- (Object) test_checkout



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'test/test_model/package.rb', line 104

def test_checkout
  group = flexmock 'generic group'
  group.should_receive(:remove_package).with(@package).times(1).and_return do
    assert true
  end
  @package.instance_variable_set '@generic_group', group
  narc1 = flexmock 'narcotic1'
  narc1.should_receive(:remove_package).with(@package).times(1).and_return do
    assert true
  end
  narc2 = flexmock 'narcotic2'
  narc2.should_receive(:remove_package).with(@package).times(1).and_return do
    assert true
  end
  @package.narcotics.push narc1, narc2
  part1 = flexmock 'part1'
  part1.should_receive(:checkout).times(1).and_return do
    assert true
  end
  part1.should_receive(:odba_delete).times(1).and_return do
    assert true
  end
  part2 = flexmock 'part1'
  part2.should_receive(:checkout).times(1).and_return do assert true end
  part2.should_receive(:odba_delete).times(1).and_return do assert true end
  @package.parts.push part1, part2
  slentry = flexmock 'sl entry'
  slentry.should_receive(:checkout).times(1).and_return do assert true end
  slentry.should_receive(:odba_delete).times(1).and_return do assert true end
  @package.instance_variable_set '@sl_entry', slentry
  @package.checkout
end

- (Object) test_commercial_forms



136
137
138
139
140
141
# File 'test/test_model/package.rb', line 136

def test_commercial_forms
  part1 = flexmock :commercial_form => 'cf1'
  part2 = flexmock :commercial_form => 'cf2'
  @package.parts.push part1, part2
  assert_equal %w{cf1 cf2}, @package.commercial_forms
end

- (Object) test_company_name



142
143
144
145
146
147
148
149
# File 'test/test_model/package.rb', line 142

def test_company_name
  @package.sequence = nil
  assert_nil @package.company_name
  comp = flexmock :name => 'Company Name'
  seq = flexmock :company => comp
  @package.sequence = seq
  assert_equal 'Company Name', @package.company_name
end

- (Boolean) test_comparable?

Returns:

  • (Boolean)


172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'test/test_model/package.rb', line 172

def test_comparable?
  part1 = flexmock :comparable_size => Dose.new(5, 'ml')
  part2 = flexmock :comparable_size => Dose.new(10, 'ml')
  @package.parts.push part1, part2

  pack = ODDB::Package.new('98')
  pack.parts.push part1, part2
  seq = StubPackageSequence.new
  seq.basename = "abc"
  pack.sequence = seq

  top = @package.comparable_size * 1.25
  bottom = @package.comparable_size * 0.75
  assert(@package.comparable?(bottom, top, pack))
end

- (Object) test_comparable_failcase



187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'test/test_model/package.rb', line 187

def test_comparable_failcase
  part1 = flexmock :comparable_size => Dose.new(5, 'ml')
  part2 = flexmock :comparable_size => Dose.new(10, 'ml')
  @package.parts.push part1, part2

  pack = ODDB::Package.new('98')
  pack.parts.push part1, part2

  top = @package.comparable_size * 1.25
  bottom = @package.comparable_size * 0.75
  # pack.basename == nil => this will be returned false
  assert_equal(false, @package.comparable?(bottom, top, pack))
end

- (Object) test_comparable_size



156
157
158
159
160
161
# File 'test/test_model/package.rb', line 156

def test_comparable_size
  part1 = flexmock :comparable_size => Dose.new(5, 'ml')
  part2 = flexmock :comparable_size => Dose.new(10, 'ml')
  @package.parts.push part1, part2
  assert_equal Dose.new(15, 'ml'), @package.comparable_size
end

- (Object) test_comparable_size__empty



168
169
170
171
# File 'test/test_model/package.rb', line 168

def test_comparable_size__empty
  assert_equal [], @package.parts
  assert_equal Dose.new(0, ''), @package.comparable_size
end

- (Object) test_comparable_size__robust



162
163
164
165
166
167
# File 'test/test_model/package.rb', line 162

def test_comparable_size__robust
  part1 = flexmock :comparable_size => Dose.new(5, 'ml')
  part2 = flexmock :comparable_size => Dose.new(10, 'mg')
  @package.parts.push part1, part2
  assert_equal Dose.new(15, ''), @package.comparable_size
end

- (Object) test_comparables1



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'test/test_model/package.rb', line 200

def test_comparables1
  seq = StubPackageSequence.new
  seq.basename = "abc"
  pack = ODDB::Package.new('98')
  pack.sequence = seq
  part = ODDB::Part.new
  part.size = '12 Tabletten'
  pack.parts.push part
  seq.active_packages = [pack]
  @package.sequence.comparables = [seq]
  part = ODDB::Part.new
  part.size = '15 Tabletten'

  @package.parts.push part
  assert_equal([pack], @package.comparables)
end

- (Object) test_comparables2



216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'test/test_model/package.rb', line 216

def test_comparables2
  seq = StubPackageSequence.new
  pack = ODDB::Package.new('98')
  part = ODDB::Part.new
  part.size = '12 Tabletten'
  pack.parts.push part
  seq.active_packages = [pack]
  @package.sequence.comparables = [seq]
  part = ODDB::Part.new
  part.size = '200 Tabletten'
  @package.parts.push part
  assert_equal([], @package.comparables)
end

- (Object) test_comparables3



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'test/test_model/package.rb', line 229

def test_comparables3
  seq = StubPackageSequence.new
  seq.basename = "abc"
  seqpack = ODDB::Package.new('97')
  seqpack.sequence = seq
  part = ODDB::Part.new
  part.size = '12 Tabletten'
  seqpack.parts.push part
  pack = ODDB::Package.new('98')
  pack.sequence = seq
  part = ODDB::Part.new
  part.size = '12 Tabletten'
  pack.parts.push part
  seq.active_packages = [pack]
  @package.sequence.comparables = [seq]
  @package.sequence.active_packages = [seqpack, @package]
  part = ODDB::Part.new
  part.size = '15 Tabletten'
  @package.parts.push part
  assert_equal([pack, seqpack], @package.comparables)
end

- (Object) test_compositions



150
151
152
153
154
155
# File 'test/test_model/package.rb', line 150

def test_compositions
  part1 = flexmock :composition => 'comp1'
  part2 = flexmock :composition => 'comp2'
  @package.parts.push part1, part2
  assert_equal %w{comp1 comp2}, @package.compositions
end

- (Object) test_create_part



250
251
252
253
254
255
256
# File 'test/test_model/package.rb', line 250

def test_create_part
  assert_equal [], @package.parts
  part = @package.create_part
  assert_instance_of Part, part
  assert_equal [part], @package.parts
  assert_equal @package, part.package
end

- (Object) test_create_sl_entry



257
258
259
260
261
# File 'test/test_model/package.rb', line 257

def test_create_sl_entry
  assert_nil(@package.sl_entry)
  @package.create_sl_entry
  assert_equal(ODDB::SlEntry, @package.sl_entry.class)
end

- (Object) test_ddd



262
263
264
265
266
267
268
269
# File 'test/test_model/package.rb', line 262

def test_ddd
  @package.sequence = nil
  assert_nil @package.ddd
  atc = flexmock :has_ddd? => true, :ddds => { 'P' => 'PDDD', 'O' => 'ODDD' }
  seq = flexmock :atc_class => atc
  @package.sequence = seq
  assert_equal 'ODDD', @package.ddd
end

- (Object) test_ddd_price



270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'test/test_model/package.rb', line 270

def test_ddd_price
  group = flexmock 'galenic_group'
  group.should_receive(:match).and_return(true)
  ddd = flexmock :dose => Dose.new(20, 'mg')
  atc = flexmock :has_ddd? => true, :ddds => { 'O' => ddd }
  seq = flexmock :atc_class => atc, :galenic_group => group,
                 :dose => Dose.new(10, 'mg'), :longevity => nil
  @package.price_public = Util::Money.new(10, 'CHF')
  @package.sequence = seq
  part = flexmock :comparable_size => Dose.new(10, 'Tabletten')
  @package.parts.push part
  assert_equal Util::Money.new(2, 'CHF'), @package.ddd_price
end

- (Object) test_ddd_price__longevity



283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'test/test_model/package.rb', line 283

def test_ddd_price__longevity
  group = flexmock 'galenic_group'
  group.should_receive(:match).and_return(true)
  ddd = flexmock :dose => Dose.new(20, 'mg')
  atc = flexmock :has_ddd? => true, :ddds => { 'O' => ddd }
  seq = flexmock :atc_class => atc, :galenic_group => group,
                 :dose => Dose.new(20, 'mg'), :longevity => 2
  @package.price_public = Util::Money.new(10, 'CHF')
  @package.sequence = seq
  part = flexmock :comparable_size => Dose.new(10, 'Tabletten')
  @package.parts.push part
  assert_equal Util::Money.new(1, 'CHF'), @package.ddd_price
end

- (Object) test_delete_part



296
297
298
299
300
301
302
303
# File 'test/test_model/package.rb', line 296

def test_delete_part
  part = flexmock(:oid => 4)
  @package.parts.push part
  @package.delete_part 1
  assert_equal [part], @package.parts
  @package.delete_part 4
  assert_equal [], @package.parts
end

- (Object) test_delete_sl_entry



304
305
306
307
308
309
310
311
312
313
# File 'test/test_model/package.rb', line 304

def test_delete_sl_entry
  @package.instance_variable_set '@sl_entry', flexmock('slentry')
  reg = flexmock :packages => [@package]
  reg.should_receive(:generic_type=).with(nil).and_return do assert true end
  reg.should_receive(:odba_isolated_store).and_return do assert true end
  @package.deductible = 'deductible'
  @package.delete_sl_entry
  assert_nil @package.sl_entry
  assert_nil @package.deductible
end

- (Object) test_feedback



314
315
316
317
318
319
320
321
# File 'test/test_model/package.rb', line 314

def test_feedback
  fb1 = flexmock :oid => 12
  fb2 = flexmock :oid => 16
  @package.feedbacks.push fb1, fb2
  assert_equal(fb1, @package.(12))
  assert_equal(fb2, @package.('16'))
  assert_nil(@package.(1))
end

- (Object) test_generic_group



322
323
324
# File 'test/test_model/package.rb', line 322

def test_generic_group
  assert_respond_to(@package, :generic_group)
end

- (Object) test_generic_group_comparables



334
335
336
337
338
# File 'test/test_model/package.rb', line 334

def test_generic_group_comparables
  group = flexmock :packages => [ 'other', @package, 'third' ]
  @package.instance_variable_set '@generic_group', group
  assert_equal ['other', 'third'], @package.generic_group_comparables
end

- (Object) test_generic_group_writer



325
326
327
328
329
330
331
332
333
# File 'test/test_model/package.rb', line 325

def test_generic_group_writer
  generic_group = StubPackageGenericGroup.new
  assert_nil(generic_group.package)
  @package.generic_group = generic_group
  assert_equal(@package, generic_group.package)
  assert_nil(generic_group.removed)
  @package.generic_group = nil
  assert_equal(true, generic_group.removed)
end

- (Object) test_good_result



339
340
341
342
343
# File 'test/test_model/package.rb', line 339

def test_good_result
  @package.sequence = flexmock :basename => 'Something or Other'
  assert_equal true, @package.good_result?('Something')
  assert_equal false, @package.good_result?('Other')
end

- (Object) test_has_generic



344
345
346
347
348
349
350
351
352
353
354
355
# File 'test/test_model/package.rb', line 344

def test_has_generic
  assert_equal false, @package.has_generic?
  @package.sequence = flexmock :comparables => [], :public_packages => []
  @package.instance_variable_set '@generic_type', :original
  @package.parts.push flexmock(:comparable_size => Dose.new(5, 'ml'))
  assert_equal false, @package.has_generic?
  group = flexmock :packages => [ 'other', @package, 'third' ]
  @package.instance_variable_set '@generic_group', group
  assert_equal true, @package.has_generic?
  @package.instance_variable_set '@generic_type', :generic
  assert_equal false, @package.has_generic?
end

- (Object) test_has_price



356
357
358
359
360
# File 'test/test_model/package.rb', line 356

def test_has_price
  assert_equal false, @package.has_price?
  @package.price_public = 10
  assert_equal true, @package.has_price?
end

- (Object) test_has_price_history



361
362
363
364
365
366
367
# File 'test/test_model/package.rb', line 361

def test_has_price_history
  assert_equal false, @package.has_price_history?
  @package.price_public = 10
  assert_equal false, @package.has_price_history?
  @package.price_public = 20
  assert_equal true, @package.has_price_history?
end

- (Object) test_ikscd_writer



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'test/test_model/package.rb', line 368

def test_ikscd_writer
  @package.out_of_trade = true
  part = flexmock 'part'
  part.should_receive(:fix_pointers).times(1).and_return do assert true end
  @package.parts.push part
  pacs = {'012' => @package }
  seqptr = Persistence::Pointer.new [:sequence => 'scd']
  seq = flexmock :packages => pacs, :pointer => seqptr
  @package.sequence = seq
  slentry = flexmock 'slentry'
  slentry.should_receive(:pointer=)\
    .with(seqptr + [:package, '015'] + :sl_entry).times(1).and_return do
    assert true
  end
  slentry.should_receive(:odba_store).times(1).and_return do assert true end
  @package.instance_variable_set '@sl_entry', slentry
  @package.ikscd = '015'
  assert_equal({'015' => @package}, pacs)
  assert_equal false, @package.out_of_trade
  assert_equal seqptr + [:package, '015'], @package.pointer
end

- (Object) test_ikskey



393
394
395
396
# File 'test/test_model/package.rb', line 393

def test_ikskey
  result = @package.ikskey()
  assert_equal('12345012', result)  
end

- (Object) test_iksnr



389
390
391
392
# File 'test/test_model/package.rb', line 389

def test_iksnr
  assert_respond_to(@package, :iksnr)
  assert_equal('12345', @package.iksnr)
end

- (Object) test_initialize



55
56
57
58
# File 'test/test_model/package.rb', line 55

def test_initialize
  assert_equal('012', @package.ikscd)
  assert_not_nil(@package.oid)
end

- (Object) test_limitation



397
398
399
400
401
# File 'test/test_model/package.rb', line 397

def test_limitation
  assert_nil @package.limitation
  @package.instance_variable_set '@sl_entry', flexmock(:limitation => 'lim')
  assert_equal 'lim', @package.limitation
end

- (Object) test_limitation_text



402
403
404
405
406
# File 'test/test_model/package.rb', line 402

def test_limitation_text
  assert_nil @package.limitation_text
  @package.instance_variable_set '@sl_entry', flexmock(:limitation_text => 'lt')
  assert_equal 'lt', @package.limitation_text
end

- (Object) test_localized_name



407
408
409
410
411
412
413
414
# File 'test/test_model/package.rb', line 407

def test_localized_name
  seq = flexmock 'sequence'
  seq.should_receive(:localized_name).with(:de).and_return 'Deutsch'
  seq.should_receive(:localized_name).with(:fr).and_return 'Françaix'
  @package.sequence = seq
  assert_equal 'Deutsch', @package.localized_name(:de)
  assert_equal 'Françaix', @package.localized_name(:fr)
end

- (Object) test_most_precise_dose



415
416
417
418
419
420
421
422
423
# File 'test/test_model/package.rb', line 415

def test_most_precise_dose
  assert_nil @package.most_precise_dose
  @package.sequence.dose = 'sequence-dose'
  assert_equal 'sequence-dose', @package.most_precise_dose
  @package.ddd_dose = 'ddd-dose'
  assert_equal 'ddd-dose', @package.most_precise_dose
  @package.pretty_dose = 'pretty-dose'
  assert_equal 'pretty-dose', @package.most_precise_dose
end

- (Object) test_name_with_size



424
425
426
427
428
# File 'test/test_model/package.rb', line 424

def test_name_with_size
  @package.sequence = flexmock :name_base => 'Name'
  @package.parts.push flexmock(:size => '10 Tablette(n)')
  assert_equal 'Name, 10 Tablette(n)', @package.name_with_size
end

- (Object) test_narcotic



429
430
431
432
433
434
435
# File 'test/test_model/package.rb', line 429

def test_narcotic
  assert_equal false, @package.narcotic?
  @package.narcotics.push flexmock(:category => 'b')
  assert_equal false, @package.narcotic?
  @package.narcotics.push flexmock(:category => 'a')
  assert_equal true, @package.narcotic?
end

- (Object) test_part



445
446
447
448
449
450
451
452
453
454
455
# File 'test/test_model/package.rb', line 445

def test_part
  assert_nil @package.part(3)
  part1 = flexmock :oid => 3
  @package.parts.push part1
  assert_equal part1, @package.part(3)
  assert_nil @package.part(8)
  part2 = flexmock :oid => 7
  @package.parts.push part2
  assert_nil @package.part(8)
  assert_equal part2, @package.part(7)
end

- (Object) test_pharmacode_writer



436
437
438
439
440
441
442
443
444
# File 'test/test_model/package.rb', line 436

def test_pharmacode_writer
  assert_nil @package.pharmacode
  @package.pharmacode = '12345'
  assert_equal '12345', @package.pharmacode
  @package.pharmacode = 98765
  assert_equal '98765', @package.pharmacode
  @package.pharmacode = nil
  assert_nil @package.pharmacode
end

- (Object) test_preview



456
457
458
459
460
461
462
463
464
465
466
# File 'test/test_model/package.rb', line 456

def test_preview
  assert_nil @package.preview?
  @package.preview_with_market_date = true
  assert_nil @package.preview?
  @package.market_date = @@today
  assert_equal false, @package.preview?
  @package.market_date = @@today + 1
  assert_equal true, @package.preview?
  @package.preview_with_market_date = nil
  assert_nil @package.preview?
end

- (Object) test_price



467
468
469
470
471
472
473
474
475
476
477
# File 'test/test_model/package.rb', line 467

def test_price
  price1 = Util::Money.new 10
  price1.valid_from = Time.now - 3600
  price2 = Util::Money.new 20
  @package.price_public = price1
  @package.price_public = price2
  assert_equal price2, @package.price(:public)
  assert_equal price1, @package.price(:public, Time.now - 20)
  assert_equal price2, @package.price(:public, 0)
  assert_equal price1, @package.price(:public, 1)
end

- (Object) test_price_diff



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'test/test_model/package.rb', line 478

def test_price_diff
  values = {:price_exfactory => 12.34}
  expected = {:price_exfactory => Util::Money.new(12.34)}
  assert_equal(expected, @package.diff(values))
  @package.price_exfactory = Util::Money.new(12.34)
  assert_equal({}, @package.diff(values))
  values = {:price_exfactory => "12.34"}
  assert_equal({}, @package.diff(values))
  values = {:price_exfactory => 43.21}
  expected = {:price_exfactory => Util::Money.new(43.21)}
  assert_equal(expected, @package.diff(values))
  ## rounding errors:
  @package.price_exfactory = Util::Money.new(43.21)
  values = {:price_exfactory => 43.210000000000000000345}
  assert_equal({}, @package.diff(values))
  values = {:price_exfactory => 43.209999999999999999995}
  assert_equal({}, @package.diff(values))
end

- (Object) test_public



496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'test/test_model/package.rb', line 496

def test_public
  inactive = flexmock 'registration'
  inactive.should_receive(:active?).and_return false
  @package.sequence.registration = inactive
  assert_equal(true, @package.public?)
  @package.out_of_trade = true
  assert_equal(false, @package.public?)
  @package.refdata_override = true
  assert_equal(true, @package.public?)
  @package.market_date = Date.today + 1
  assert_equal(false, @package.public?)
  @package.market_date = Date.today
  assert_equal(true, @package.public?)
end

- (Object) test_registration_data



510
511
512
513
514
515
516
# File 'test/test_model/package.rb', line 510

def test_registration_data
  reg = flexmock :source => 'source'
  seq = flexmock :registration => reg
  assert_nil @package.source
  @package.sequence = seq
  assert_equal 'source', @package.source
end

- (Object) test_remove_narcotic



517
518
519
520
521
522
523
524
525
# File 'test/test_model/package.rb', line 517

def test_remove_narcotic
  narc = flexmock 'narcotic'
  narc.should_receive(:remove_package).with(@package).times(1).and_return do
    assert true
  end
  @package.narcotics.push narc
  @package.remove_narcotic narc
  assert_equal [], @package.narcotics
end

- (Object) test_respond_to_name_base



526
527
528
# File 'test/test_model/package.rb', line 526

def test_respond_to_name_base
  assert_respond_to(@package, :name_base)
end

- (Object) test_size



529
530
531
532
533
# File 'test/test_model/package.rb', line 529

def test_size
  @package.parts.push flexmock(:size => '10 Tabletten'),
                      flexmock(:size => '5 Tabletten')
  assert_equal '10 Tabletten + 5 Tabletten', @package.size
end

- (Object) test_sortable



534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
# File 'test/test_model/package.rb', line 534

def test_sortable
  other = Package.new '015'
  other.sequence = StubPackageSequence.new
  other.sequence.basename = 'A Name'
  @package.sequence.basename = 'Another Name'
  assert_equal [other, @package], [@package, other].sort
  @package.sequence.basename = 'A Name'
  assert_equal [@package, other], [@package, other].sort
  other.sequence.dose = 20
  @package.sequence.dose = 10
  assert_equal [@package, other], [other, @package].sort
  other.sequence.dose = 10
  assert_equal [@package, other], [@package, other].sort
  @package.parts.push flexmock(:comparable_size => 20)
  other.parts.push flexmock(:comparable_size => 10)
  assert_equal [other, @package], [@package, other].sort
end

- (Object) test_substances



551
552
553
554
555
556
557
558
# File 'test/test_model/package.rb', line 551

def test_substances
  act1 = flexmock :substance => 'sub1'
  act2 = flexmock :substance => 'sub2'
  act3 = flexmock :substance => 'sub3'
  @package.parts.push flexmock(:active_agents => [act1, act2]),
                      flexmock(:active_agents => [act3])
  assert_equal %w{sub1 sub2 sub3}, @package.substances
end