Class: TestFachinfoDocParser

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/fiparse/test/test_fachinfo_doc_parser.rb

Defined Under Namespace

Classes: StubTabDescriptor

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



32
33
34
35
36
37
38
39
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 32

def setup
  @filename = File.expand_path('data/doc/fi_df_t2.doc', 
    File.dirname(__FILE__))
  @text_handler = ODDB::FiParse::FachinfoTextHandler.new
  @parser = Rwv2.create_parser(@filename)
  @parser.set_text_handler(@text_handler)
  @parser.parse
end

- (Object) test_company1



47
48
49
50
51
52
53
54
55
56
57
58
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 47

def test_company1
  writer = @text_handler.writers.first
  chapter = writer.company
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('HELVEPHARM', chapter.heading)
  assert_equal(0, chapter.sections.size)
  writer = @text_handler.writers.last
  chapter = writer.company
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('HELVEPHARM', chapter.heading)
  assert_equal(0, chapter.sections.size)
end

- (Object) test_composition1



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 81

def test_composition1
  writer = @text_handler.writers.first
  chapter = writer.composition
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('Zusammensetzung', chapter.heading)
  assert_equal(10, chapter.sections.size)
  section = chapter.sections.first
  assert_instance_of(ODDB::Text::Section, section)
  assert_equal('Wirkstoff:', section.subheading)
  assert_equal(1, section.paragraphs.size)
  paragraph = section.paragraphs.first
  assert_instance_of(ODDB::Text::Paragraph, paragraph)
  assert_equal('Tramadolhydrochlorid.',paragraph.text)
end

- (Object) test_effects1



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 95

def test_effects1
  writer = @text_handler.writers.first
  chapter = writer.effects
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('Eigenschaften/Wirkungen', chapter.heading)
  assert_equal(1, chapter.sections.size)
  section = chapter.sections.first
  assert_instance_of(ODDB::Text::Section, section)
  assert_equal('', section.subheading)
  assert_equal(2, section.paragraphs.size)
  paragraph = section.paragraphs.first
  assert_instance_of(ODDB::Text::Paragraph, paragraph)
  assert_equal('Tramadol ist ein Cyclohexanol-Derivat mit opiatagonistischen Eigenschaften. Die Wirkung von Tramadol beruht teilweise auf adrenerge Effekte der Muttersubstanz. Sein aktiver Hauptmetabolit O-Desmethyl-Tramadol ist ein nicht selektiver, reiner Agonist der Opiatrezeptoren, ohne Bevorzugung bestimmter Populationen.',paragraph.text)
end

- (Object) test_expand_tabs1a



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 136

def test_expand_tabs1a
  str = '12345 67890'
  assert_equal(str, @text_handler.expand_tabs(str))
  @text_handler.tabs = [
    0,
    959,
    4795,
    5754,
    6713,
    7672,
    8631,
    1701,
    2268,
    4253,
  ].collect { |pos|
    td =  StubTabDescriptor.new
    td.position = pos
    td
  }
  str = "Applikations-\tEinzeldosis"
  expected = "Applikations-    Einzeldosis"
  assert_equal(expected, @text_handler.expand_tabs(str))
  str = "Applikations-\tEinzeldosis\tTagesdosis"
  expected = "Applikations-    Einzeldosis              Tagesdosis"
  assert_equal(expected, @text_handler.expand_tabs(str))
end

- (Object) test_expand_tabs1b



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 162

def test_expand_tabs1b
  @text_handler.tabs = [
    0,
    959,
    4795,
    5754,
    6713,
    7672,
    8631,
    1701,
    2268,
    4253,
  ].collect { |pos|
    td =  StubTabDescriptor.new
    td.position = pos
    td
  }
  str = "Kapseln\t\t1 Kapsel (50 mg)\tbis zu 8 Kapseln"
  expected = "Kapseln          1 Kapsel (50 mg)         bis zu 8 Kapseln"
  assert_equal(expected, @text_handler.expand_tabs(str))
end

- (Object) test_galenic_form_de1



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

def test_galenic_form_de1
  writer = @text_handler.writers.first
  chapter = writer.galenic_form
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('', chapter.heading)
  assert_equal(1, chapter.sections.size)
  section = chapter.sections.first
  assert_instance_of(ODDB::Text::Section, section)
  assert_equal("Zentralwirksames Analgetikum\n", section.subheading)
  assert_equal(0, section.paragraphs.size)
end

- (Object) test_galenic_form_fr1



70
71
72
73
74
75
76
77
78
79
80
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 70

def test_galenic_form_fr1
  writer = @text_handler.writers.last
  chapter = writer.galenic_form
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('', chapter.heading)
  assert_equal(1, chapter.sections.size)
  section = chapter.sections.first
  assert_instance_of(ODDB::Text::Section, section)
  assert_match(/Analg.+sique d\'action centrale/, section.subheading)
  assert_equal(0, section.paragraphs.size)
end

- (Object) test_indications1



116
117
118
119
120
121
122
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 116

def test_indications1
  writer = @text_handler.writers.first
  chapter = writer.indications
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_match(/Indikationen\/Anwendungsm.*glichkeiten/, chapter.heading)
  assert_equal(1, chapter.sections.size)
end

- (Object) test_kinetic1



109
110
111
112
113
114
115
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 109

def test_kinetic1
  writer = @text_handler.writers.first
  chapter = writer.kinetic
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('Pharmakokinetik', chapter.heading)
  assert_equal(6, chapter.sections.size)
end

- (Object) test_name1



40
41
42
43
44
45
46
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 40

def test_name1
  assert_equal(2, @text_handler.writers.size)
  writer = @text_handler.writers.first
  assert_match(/Tramadol Helvepharm.* Kapseln\/Tropfen\/Suppositorien/, writer.name)
  writer = @text_handler.writers.last
  assert_match(/Tramadol Helvepharm.* Capsules\/Gouttes\/Suppositoires/, writer.name)
end

- (Object) test_usage1



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'ext/fiparse/test/test_fachinfo_doc_parser.rb', line 123

def test_usage1
  writer = @text_handler.writers.first
  chapter = writer.usage
  assert_instance_of(ODDB::Text::Chapter, chapter)
  assert_equal('Dosierung/Anwendung', chapter.heading)
  assert_equal(10, chapter.sections.size)
  section = chapter.sections.first
  assert_equal(5, section.paragraphs.size)
  paragraph = section.paragraphs.at(1)
  expected = /\-+\nApplikations\-    Einzeldosis              Tagesdosis\nform\n\-+\nKapseln          1 Kapsel \(50 mg\)         bis zu 8 Kapseln\nTropfen          20 Tropfen \(50 mg\)       bis zu\n.* 20 Tropfen\nSuppositorien    1 Suppositorium          bis zu\n +\(100 mg\)                 4 Suppositorien \n\-+\n/
  assert_equal(true, paragraph.preformatted?)
  assert_match(expected, paragraph.text)
end