Class: ODDB::OdbaExporter::TestAcnamLine

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
ext/export/test/test_oddbdat.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'ext/export/test/test_oddbdat.rb', line 156

def setup
  @package = ODDB::Package.new('12')
  @package.sequence = flexmock('sequence') do |seq|
    seq.should_receive(:galenic_forms).and_return(['galenic_forms'])
    seq.should_receive(:dose).and_return(flexmock('dose') do |dose|
      dose.should_receive(:is_a?).and_return(true)
      dose.should_receive(:qty).and_return('qty')
      dose.should_receive(:unit).and_return('unit')
    end)
    seq.should_receive(:name).and_return('name')
    seq.should_receive(:name_base).and_return('name_base')
    seq.should_receive(:name_descr).and_return('name_descr')
  end
  flexstub(Date).should_receive(:"today.strftime").and_return('20110203000000')
end

- (Object) test_structure__package_parts_nil_case



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'ext/export/test/test_oddbdat.rb', line 171

def test_structure__package_parts_nil_case
  flexstub(@package) do |pack|
    pack.should_receive(:oid).and_return(123)
    pack.should_receive(:commercial_forms).and_return(['commercial_forms'])
    pack.should_receive(:"comparable_size.qty").and_return('comparable_size.qty')
    pack.should_receive(:parts).and_return([])
  end

  @acnamline = AcnamLine.new(@package)
  expected = {
    1=>"03",
    2=>"20110203000000",
    3=>"1",
    4=>123,
    5=>"D",
    6=>"4",
    7=>"name",
    8=>"name_base",
    9=>"name_descr",
    11=>"galenic_forms",
    12=>"qty",
    13=>"unit",
    16=>"",
    17=>"commercial_forms",
    18=>"comparable_size.qty",
    19=>"commercial_forms",
  }
  assert_equal(expected.sort, @acnamline.structure.sort)
end

- (Object) test_structure__package_parts_not_nil_case



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'ext/export/test/test_oddbdat.rb', line 200

def test_structure__package_parts_not_nil_case
  count = 0
  part = flexmock('part') do |mock|
    mock.should_receive(:measure).and_return(count+=1)
    mock.should_receive(:multi).and_return('multi')
  end
  parts = [part, part, part]
  flexstub(@package) do |pack|
    pack.should_receive(:oid).and_return(123)
    pack.should_receive(:commercial_forms).and_return(['commercial_forms'])
    pack.should_receive(:"comparable_size.qty").and_return('comparable_size.qty')
    pack.should_receive(:parts).and_return(parts)
  end

  @acnamline = AcnamLine.new(@package)
  expected = {
    1=>"03",
    2=>"20110203000000",
    3=>"1",
    4=>123,
    5=>"D",
    6=>"4",
    7=>"name",
    8=>"name_base",
    9=>"name_descr",
    11=>"galenic_forms",
    12=>"qty",
    13=>"unit",
    16=>"multi",
    17=>"commercial_forms",
    18=>"comparable_size.qty",
    19=>"commercial_forms",
  }
  assert_equal(expected.sort, @acnamline.structure.sort)
end