Class: ODDB::OdbaExporter::TestOddbDatExport

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



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

def setup
   @app = flexmock('app') do |ap|
    ap.should_receive(:atc_classes).and_return(flexmock('atc_classes') do |atc|
       atc.should_receive(:values).and_return([])
     end)
     ap.should_receive(:each_galenic_form).and_yield(flexmock('galform') do |gal|
       gal.should_receive(:odba_id).and_return('gal.odba_id')
     end)
     ap.should_receive(:substances).and_return([])
     ap.should_receive(:companies).and_return([])
   end
   @oddbdatexport = OddbDatExport.new(@app)

end

- (Object) test_export



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

def test_export
  flexstub(@app) do |ap|
    ap.should_receive(:each_package).and_yield(flexmock('pac') do |pac|
      pac.should_receive(:odba_id).and_return('pac.odba_id')
      pac.should_receive(:parts).and_return('not empty')
    end)
  end

  # white box test: check 'files' value
  flexstub(OddbDatExport::EXPORT_SERVER) do |drb|
    expected = ["export_oddbdat"] * 5
    drb.should_receive(:compress_many).with(String, String, expected)
  end

  # black box test
  assert_equal([], @oddbdatexport.export)
end

- (Object) test_export__dose_missing



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'test/test_plugin/oddbdat_export.rb', line 60

def test_export__dose_missing
  flexstub(@app) do |ap|
    ap.should_receive(:each_package).and_yield(flexmock('pac') do |pac|
      pac.should_receive(:odba_id).and_return('pac.odba_id')
      pac.should_receive(:parts).and_return('')
      pac.should_receive(:basename).and_return('pac.basename')
      pac.should_receive(:iksnr).and_return('pac.iksnr')
      pac.should_receive(:"sequence.seqnr").and_return('pac.sequence.seqnr')
      pac.should_receive(:ikscd).and_return('pac.iksce')
    end)
  end
 
  expected = [["pac.basename", "pac.iksnr", "pac.sequence.seqnr", "pac.iksce"]]
  assert_equal(expected, @oddbdatexport.export)
end

- (Object) test_export_fachinfos



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'test/test_plugin/oddbdat_export.rb', line 75

def test_export_fachinfos
  flexstub(@app) do |ap|
    ap.should_receive(:fachinfos).and_return([])
  end

  # white box test: check 'files' value
  flexstub(OddbDatExport::EXPORT_SERVER) do |drb|
    expected = "export_oddbdat"
    drb.should_receive(:compress).with(String, expected)
  end
 
  # black box test
  assert_equal(nil, @oddbdatexport.export_fachinfos)
end