Class: ODDB::TestYamlExporter

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) test_check_fachinfos_no_warning_case



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'test/test_plugin/yaml.rb', line 19

def test_check_fachinfos_no_warning_case
  flexfachinfo = flexmock do |fachinfo|
    descriptions = {'de'=>'abc', 'fr'=>'def'}
    fachinfo.should_receive(:descriptions).and_return(descriptions) 
  end
  fachinfos = {1=>flexfachinfo}
  flexapp = flexmock do |app|
    app.should_receive(:fachinfos).and_return(fachinfos)
  end
  @exporter = YamlExporter.new(flexapp)

  flexstub(Log) do |logclass|
    # This 'times' is a check point in this test case
    # If there is no missing data, Log instance is not created
    logclass.should_receive(:new).times(0)
  end
  
  assert_equal(0, @exporter.check_fachinfos.values.flatten.length)
end

- (Object) test_check_fachinfos_warning_case



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'test/test_plugin/yaml.rb', line 38

def test_check_fachinfos_warning_case
  flexfachinfo = flexmock do |fachinfo|
    descriptions = {'de'=>'abc'}
    fachinfo.should_receive(:descriptions).and_return(descriptions) 
    fachinfo.should_receive(:odba_id).and_return(123)
    fachinfo.should_receive(:company_name).and_return('ywesee')
    fachinfo.should_receive(:name_base).and_return('drug')
  end
  fachinfos = {1=>flexfachinfo}
  flexapp = flexmock do |app|
    app.should_receive(:fachinfos).and_return(fachinfos)
  end
  @exporter = YamlExporter.new(flexapp)

  flexstub(ODBA) do |odba|
    odba.should_receive(:cache).and_return do 
      flexmock do |obj|
        obj.should_receive(:fetch).and_return do 
          flexmock do |obj2|
            obj2.should_receive(:iksnrs).and_return([1,2,3])
          end
        end
      end
    end
  end

  flexstub(Log) do |logclass|
    # This 'times' is a check point in this test case
    # If there is missing data, Log instance is created once
    logclass.should_receive(:new).times(1).and_return do 
      flexmock do |logobj|
        logobj.should_receive(:report=)
        logobj.should_receive(:notify)
      end
    end
  end
 
  result = @exporter.check_fachinfos
  assert_equal(5, result.values.flatten.length)
  assert_equal(['ywesee','drug',1,2,3], result['fr'][0])
end