oddb2xml 2.2.6 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/builder_spec.rb CHANGED
@@ -10,7 +10,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
10
10
  refdata = article.elements['REF_DATA'].text
11
11
  smno = article.elements['SMNO'] ? article.elements['SMNO'].text : 'nil'
12
12
  puts "checking doc for gtin #{gtin} isRefdata #{isRefdata} == #{refdata}. SMNO: #{smno} #{name}" if $VERBOSE
13
- article.elements['REF_DATA'].text.should == isRefdata.to_s
13
+ expect(article.elements['REF_DATA'].text).to eq(isRefdata.to_s)
14
14
  article
15
15
  end
16
16
 
@@ -22,7 +22,7 @@ def check_article_IGM_format(line, price_kendural=825, add_80_percents=false)
22
22
  price_exf = line[60..65].to_i
23
23
  price_reseller = line[66..71].to_i
24
24
  price_public = line[66..71].to_i
25
- typ.should eq '11'
25
+ expect(typ).to eq '11'
26
26
  puts "check_article_IGM_format: #{price_exf} #{price_public} CKZL is #{ckzl} CIKS is #{ciks} name #{name} " if $VERBOSE
27
27
  found_SL = false
28
28
  found_non_SL = false
@@ -30,26 +30,26 @@ def check_article_IGM_format(line, price_kendural=825, add_80_percents=false)
30
30
  if /7680353660163\d$/.match(line) # KENDURAL Depottabl 30 Stk
31
31
  puts "found_SL for #{line}" if $VERBOSE
32
32
  found_SL = true
33
- line[60..65].should eq '000491'
34
- price_exf.should eq 491
35
- ckzl.should eq '1'
36
- price_public.should eq price_kendural # this is a SL-product. Therefore we may not have a price increase
37
- line[66..71].should eq '000'+price_kendural.to_s # the dat format requires leading zeroes and not point
33
+ expect(line[60..65]).to eq '000491'
34
+ expect(price_exf).to eq 491
35
+ expect(ckzl).to eq '1'
36
+ expect(price_public).to eq price_kendural # this is a SL-product. Therefore we may not have a price increase
37
+ expect(line[66..71]).to eq '000'+price_kendural.to_s # the dat format requires leading zeroes and not point
38
38
  end
39
39
 
40
40
  if /7680403330459\d$/.match(line) # CARBADERM
41
41
  found_non_SL = true
42
42
  puts "found_non_SL for #{line}" if $VERBOSE
43
- ckzl.should eq '3'
43
+ expect(ckzl).to eq '3'
44
44
  if add_80_percents
45
- price_reseller.should eq 2919 # = 1545*1.8 this is a non SL-product. Therefore we must increase its price as requsted
46
- line[66..71].should eq '002919' # dat format requires leading zeroes and not poin
45
+ expect(price_reseller).to eq 2919 # = 1545*1.8 this is a non SL-product. Therefore we must increase its price as requsted
46
+ expect(line[66..71]).to eq '002919' # dat format requires leading zeroes and not poin
47
47
  else
48
- price_reseller.should eq 2770 # this is a non SL-product, but no price increase was requested
49
- line[66..71].should eq '002770' # the dat format requires leading zeroes and not point
48
+ expect(price_reseller).to eq 2770 # this is a non SL-product, but no price increase was requested
49
+ expect(line[66..71]).to eq '002770' # the dat format requires leading zeroes and not point
50
50
  end
51
- line[60..65].should eq '001622' # the dat format requires leading zeroes and not point
52
- price_exf.should eq 1622 # this is a non SL-product, but no price increase was requested
51
+ expect(line[60..65]).to eq '001622' # the dat format requires leading zeroes and not point
52
+ expect(price_exf).to eq 1622 # this is a non SL-product, but no price increase was requested
53
53
  end
54
54
  return [found_SL, found_non_SL]
55
55
  end
@@ -57,8 +57,8 @@ end
57
57
  def check_validation_via_xsd
58
58
  @oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb2xml.xsd'))
59
59
  @oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb_calc.xsd'))
60
- File.exists?(@oddb2xml_xsd).should eq true
61
- File.exists?(@oddb_calc_xsd).should eq true
60
+ expect(File.exists?(@oddb2xml_xsd)).to eq true
61
+ expect(File.exists?(@oddb_calc_xsd)).to eq true
62
62
  files = Dir.glob('*.xml')
63
63
  xsd_oddb2xml = Nokogiri::XML::Schema(File.read(@oddb2xml_xsd))
64
64
  xsd_oddb_calc = Nokogiri::XML::Schema(File.read(@oddb_calc_xsd))
@@ -72,7 +72,7 @@ def check_validation_via_xsd
72
72
  if error.message
73
73
  puts "Failed validating #{file} with #{File.size(file)} bytes using XSD from #{@oddb2xml_xsd}"
74
74
  end
75
- error.message.should be_nil
75
+ expect(error.message).to be_nil
76
76
  end
77
77
  }
78
78
  end
@@ -81,31 +81,31 @@ def checkPrices(increased = false)
81
81
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
82
82
 
83
83
  sofradex = checkAndGetArticleWithGTIN(doc, Oddb2xml::SOFRADEX_GTIN)
84
- sofradex.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text.should eq Oddb2xml::SOFRADEX_PRICE_ZURROSE.to_s
85
- sofradex.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text.should eq Oddb2xml::SOFRADEX_PRICE_ZURROSEPUB.to_s
84
+ expect(sofradex.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text).to eq Oddb2xml::SOFRADEX_PRICE_ZURROSE.to_s
85
+ expect(sofradex.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text).to eq Oddb2xml::SOFRADEX_PRICE_ZURROSEPUB.to_s
86
86
 
87
87
  lansoyl = checkAndGetArticleWithGTIN(doc, Oddb2xml::LANSOYL_GTIN)
88
- lansoyl.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text.should eq Oddb2xml::LANSOYL_PRICE_ZURROSE.to_s
89
- lansoyl.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text.should eq Oddb2xml::LANSOYL_PRICE_ZURROSEPUB.to_s
88
+ expect(lansoyl.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text).to eq Oddb2xml::LANSOYL_PRICE_ZURROSE.to_s
89
+ expect(lansoyl.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text).to eq Oddb2xml::LANSOYL_PRICE_ZURROSEPUB.to_s
90
90
 
91
91
  desitin = checkAndGetArticleWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
92
- desitin.elements["ARTPRI[PTYP='PPUB']/PRICE"].text.should eq Oddb2xml::LEVETIRACETAM_PRICE_PPUB.to_s
93
- desitin.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text.should eq Oddb2xml::LEVETIRACETAM_PRICE_ZURROSE.to_s
94
- desitin.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text.to_f.should eq Oddb2xml::LEVETIRACETAM_PRICE_PPUB.to_f
92
+ expect(desitin.elements["ARTPRI[PTYP='PPUB']/PRICE"].text).to eq Oddb2xml::LEVETIRACETAM_PRICE_PPUB.to_s
93
+ expect(desitin.elements["ARTPRI[PTYP='ZURROSE']/PRICE"].text).to eq Oddb2xml::LEVETIRACETAM_PRICE_ZURROSE.to_s
94
+ expect(desitin.elements["ARTPRI[PTYP='ZURROSEPUB']/PRICE"].text.to_f).to eq Oddb2xml::LEVETIRACETAM_PRICE_PPUB.to_f
95
95
  if increased
96
- lansoyl.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text.should eq Oddb2xml::LANSOYL_PRICE_RESELLER_PUB.to_s
97
- sofradex.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text.should eq Oddb2xml::SOFRADEX_PRICE_RESELLER_PUB.to_s
98
- desitin.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text.should eq Oddb2xml::LEVETIRACETAM_PRICE_RESELLER_PUB.to_s
96
+ expect(lansoyl.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text).to eq Oddb2xml::LANSOYL_PRICE_RESELLER_PUB.to_s
97
+ expect(sofradex.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text).to eq Oddb2xml::SOFRADEX_PRICE_RESELLER_PUB.to_s
98
+ expect(desitin.elements["ARTPRI[PTYP='RESELLERPUB']/PRICE"].text).to eq Oddb2xml::LEVETIRACETAM_PRICE_RESELLER_PUB.to_s
99
99
  else
100
- lansoyl.elements["ARTPRI[PTYP='RESELLERPUB']"].should eq nil
101
- sofradex.elements["ARTPRI[PTYP='RESELLERPUB']"].should eq nil
102
- desitin.elements["ARTPRI[PTYP='RESELLERPUB']"].should eq nil
100
+ expect(lansoyl.elements["ARTPRI[PTYP='RESELLERPUB']"]).to eq nil
101
+ expect(sofradex.elements["ARTPRI[PTYP='RESELLERPUB']"]).to eq nil
102
+ expect(desitin.elements["ARTPRI[PTYP='RESELLERPUB']"]).to eq nil
103
103
  end
104
104
  end
105
105
 
106
106
  def checkAndGetArticleXmlName(tst=nil)
107
107
  article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
108
- File.exists?(article_xml).should eq true
108
+ expect(File.exists?(article_xml)).to eq true
109
109
  FileUtils.cp(article_xml, File.join(Oddb2xml::WorkDir, "tst-#{tst}.xml")) if tst
110
110
  article_xml
111
111
  end
@@ -114,8 +114,8 @@ def checkAndGetProductWithGTIN(doc, gtin)
114
114
  products = XPath.match( doc, "//PRD[GTIN=#{gtin.to_s}]")
115
115
  gtins = XPath.match( doc, "//PRD[GTIN=#{gtin.to_s}]/GTIN")
116
116
  binding.pry unless gtins.size == 1
117
- gtins.size.should eq 1
118
- gtins.first.text.should eq gtin.to_s
117
+ expect(gtins.size).to eq 1
118
+ expect(gtins.first.text).to eq gtin.to_s
119
119
  # return product
120
120
  return products.size == 1 ? products.first : nil
121
121
  end
@@ -123,8 +123,8 @@ end
123
123
  def checkAndGetArticleWithGTIN(doc, gtin)
124
124
  articles = XPath.match( doc, "//ART[ARTBAR/BC=#{gtin}]")
125
125
  gtins = XPath.match( doc, "//ART[ARTBAR/BC=#{gtin}]/ARTBAR/BC")
126
- gtins.size.should eq 1
127
- gtins.first.text.should eq gtin.to_s
126
+ expect(gtins.size).to eq 1
127
+ expect(gtins.first.text).to eq gtin.to_s
128
128
  gtins.first
129
129
  # return article
130
130
  return articles.size == 1 ? articles.first : nil
@@ -136,60 +136,62 @@ def checkArticleXml(checkERYTHROCIN = true)
136
136
  # check articles
137
137
  doc = REXML::Document.new IO.read(article_filename)
138
138
  checkAndGetArticleWithGTIN(doc, Oddb2xml::THREE_TC_GTIN)
139
+
139
140
  desitin = checkAndGetArticleWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
140
- desitin.should_not eq nil
141
+ expect(desitin).not_to eq nil
141
142
  # TODO: why is this now nil? desitin.elements['ATC'].text.should == 'N03AX14'
142
- desitin.elements['DSCRD'].text.should == "LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk"
143
- desitin.elements['DSCRF'].text.should == 'LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce'
144
- desitin.elements['REF_DATA'].text.should == '1'
145
- desitin.elements['PHAR'].text.should == '5819012'
146
- desitin.elements['SMCAT'].text.should == 'B'
147
- desitin.elements['SMNO'].text.should == '62069008'
148
- desitin.elements['VAT'].text.should == '2'
149
- desitin.elements['PRODNO'].text.should == '620691'
150
- desitin.elements['SALECD'].text.should == 'A'
151
- desitin.elements['CDBG'].text.should == 'N'
152
- desitin.elements['BG'].text.should == 'N'
143
+ expect(desitin.elements['DSCRD'].text).to eq("LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk")
144
+ expect(desitin.elements['DSCRF'].text).to eq('LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce')
145
+ expect(desitin.elements['REF_DATA'].text).to eq('1')
146
+ expect(desitin.elements['PHAR'].text).to eq('5819012')
147
+ expect(desitin.elements['SMCAT'].text).to eq('B')
148
+ expect(desitin.elements['SMNO'].text).to eq('62069008')
149
+ expect(desitin.elements['VAT'].text).to eq('2')
150
+ expect(desitin.elements['PRODNO'].text).to eq('620691')
151
+ expect(desitin.elements['SALECD'].text).to eq('A')
152
+ expect(desitin.elements['CDBG'].text).to eq('N')
153
+ expect(desitin.elements['BG'].text).to eq('N')
153
154
 
154
155
  erythrocin_gtin = '7680202580475' # picked up from zur rose
155
156
  erythrocin = checkAndGetArticleWithGTIN(doc, erythrocin_gtin)
156
- erythrocin.elements['DSCRD'].text.should == "ERYTHROCIN i.v. Trockensub 1000 mg Amp" if checkERYTHROCIN
157
+ expect(erythrocin.elements['DSCRD'].text).to eq("ERYTHROCIN i.v. Trockensub 1000 mg Amp") if checkERYTHROCIN
157
158
 
158
159
  lansoyl = checkAndGetArticleWithGTIN(doc, Oddb2xml::LANSOYL_GTIN)
159
- lansoyl.elements['DSCRD'].text.should eq 'LANSOYL Gel 225 g'
160
- lansoyl.elements['REF_DATA'].text.should eq '1'
161
- lansoyl.elements['SMNO'].text.should eq '32475019'
162
- lansoyl.elements['PHAR'].text.should eq '0023722'
163
- lansoyl.elements['ARTCOMP/COMPNO'].text.should == '7601001002012'
160
+ expect(lansoyl.elements['DSCRD'].text).to eq 'LANSOYL Gel 225 g'
161
+ expect(lansoyl.elements['REF_DATA'].text).to eq '1'
162
+ expect(lansoyl.elements['SMNO'].text).to eq '32475019'
163
+ expect(lansoyl.elements['PHAR'].text).to eq '0023722'
164
+ expect(lansoyl.elements['ARTCOMP/COMPNO'].text).to eq('7601001002012')
164
165
 
165
166
  zyvoxid = checkAndGetArticleWithGTIN(doc, Oddb2xml::ZYVOXID_GTIN)
166
- zyvoxid.elements['DSCRD'].text.should eq 'ZYVOXID Filmtabl 600 mg 10 Stk'
167
+ expect(zyvoxid.elements['DSCRD'].text).to eq 'ZYVOXID Filmtabl 600 mg 10 Stk'
167
168
 
168
- XPath.match( doc, "//LIMPTS" ).size.should >= 1
169
+ expect(XPath.match( doc, "//LIMPTS" ).size).to be >= 1
169
170
  # TODO: desitin.elements['QTY'].text.should eq '250 mg'
170
171
  end
171
172
 
172
173
  def checkProductXml
173
174
  product_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_product.xml'))
174
- File.exists?(product_filename).should eq true
175
+ expect(File.exists?(product_filename)).to eq true
175
176
 
176
177
  # check products
177
178
  doc = REXML::Document.new IO.read(product_filename)
179
+
178
180
  desitin = checkAndGetProductWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
179
- desitin.elements['ATC'].text.should == 'N03AX14'
180
- desitin.elements['DSCRD'].text.should == "LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk"
181
- desitin.elements['DSCRF'].text.should == 'LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce'
182
- desitin.elements['PRODNO'].text.should eq '620691'
183
- desitin.elements['IT'].text.should eq '01.07.1.'
184
- desitin.elements['PackGrSwissmedic'].text.should eq '30'
185
- desitin.elements['EinheitSwissmedic'].text.should eq 'Tablette(n)'
186
- desitin.elements['SubstanceSwissmedic'].text.should eq 'levetiracetamum'
187
- desitin.elements['CompositionSwissmedic'].text.should eq 'levetiracetamum 250 mg, excipiens pro compressi obducti pro charta.'
188
-
189
- desitin.elements['CPT/CPTCMP/LINE'].text.should eq '0'
190
- desitin.elements['CPT/CPTCMP/SUBNO'].text.should eq '9'
191
- desitin.elements['CPT/CPTCMP/QTY'].text.should eq '250'
192
- desitin.elements['CPT/CPTCMP/QTYU'].text.should eq 'mg'
181
+ expect(desitin.elements['ATC'].text).to eq('N03AX14')
182
+ expect(desitin.elements['DSCRD'].text).to eq("LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk")
183
+ expect(desitin.elements['DSCRF'].text).to eq('LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce')
184
+ expect(desitin.elements['PRODNO'].text).to eq '620691'
185
+ expect(desitin.elements['IT'].text).to eq '01.07.1.'
186
+ expect(desitin.elements['PackGrSwissmedic'].text).to eq '30'
187
+ expect(desitin.elements['EinheitSwissmedic'].text).to eq 'Tablette(n)'
188
+ expect(desitin.elements['SubstanceSwissmedic'].text).to eq 'levetiracetamum'
189
+ expect(desitin.elements['CompositionSwissmedic'].text).to eq 'levetiracetamum 250 mg, excipiens pro compressi obducti pro charta.'
190
+
191
+ expect(desitin.elements['CPT/CPTCMP/LINE'].text).to eq '0'
192
+ expect(desitin.elements['CPT/CPTCMP/SUBNO'].text).to eq '10'
193
+ expect(desitin.elements['CPT/CPTCMP/QTY'].text).to eq '250'
194
+ expect(desitin.elements['CPT/CPTCMP/QTYU'].text).to eq 'mg'
193
195
 
194
196
  checkAndGetProductWithGTIN(doc, Oddb2xml::THREE_TC_GTIN)
195
197
  checkAndGetProductWithGTIN(doc, Oddb2xml::ZYVOXID_GTIN)
@@ -199,19 +201,19 @@ def checkProductXml
199
201
  puts "checkProductXml has #{XPath.match( doc, "//GTIN" ).find_all{|x| true}.size} GTIN"
200
202
  puts "checkProductXml has #{XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size} PRODNO"
201
203
  end
202
- XPath.match( doc, "//PRD" ).find_all{|x| true}.size.should == NrPackages
203
- XPath.match( doc, "//GTIN" ).find_all{|x| true}.size.should == NrPackages
204
- XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should == NrProdno
204
+ expect(XPath.match( doc, "//PRD" ).find_all{|x| true}.size).to eq(NrPackages)
205
+ expect(XPath.match( doc, "//GTIN" ).find_all{|x| true}.size).to eq(NrPackages)
206
+ expect(XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size).to eq(NrProdno)
205
207
 
206
208
  hirudoid = checkAndGetProductWithGTIN(doc, Oddb2xml::HIRUDOID_GTIN)
207
- hirudoid.elements['ATC'].text.should == 'C05BA01' # modified by atc.csv!
209
+ expect(hirudoid.elements['ATC'].text).to eq('C05BA01') # modified by atc.csv!
208
210
  end
209
211
 
210
212
  describe Oddb2xml::Builder do
211
213
  NrExtendedArticles = 86
212
214
  NrSubstances = 12
213
- NrProdno = 21
214
- NrPackages = 22
215
+ NrProdno = 23
216
+ NrPackages = 24
215
217
  RegExpDesitin = /1125819012LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk/
216
218
  include ServerMockHelper
217
219
  def common_run_init
@@ -228,15 +230,15 @@ describe Oddb2xml::Builder do
228
230
  before(:all) do
229
231
  common_run_init
230
232
  options = Oddb2xml::Options.new
231
- @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options.opts).run }
232
- # Oddb2xml::Cli.new(options.opts).run # to debug
233
+ # @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options.opts).run }
234
+ Oddb2xml::Cli.new(options.opts).run # to debug
233
235
  @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
234
236
  @doc = Nokogiri::XML(File.open(@article_xml))
235
237
  @rexml = REXML::Document.new File.read(@article_xml)
236
238
  end
237
239
 
238
240
  it 'should return produce a oddb_article.xml' do
239
- File.exists?(@article_xml).should eq true
241
+ expect(File.exists?(@article_xml)).to eq true
240
242
  end
241
243
 
242
244
  it 'oddb_article.xml should contain a SHA256' do
@@ -255,12 +257,18 @@ describe Oddb2xml::Builder do
255
257
 
256
258
  it 'should have a correct insulin (gentechnik) for 7680532900196' do
257
259
  expect(XPath.match( @rexml, "//ART/[BC='7680532900196']").size).to eq 1
258
- expect(XPath.match( @rexml, "//ART//GEN_PRODUCTION").size).to eq 1
260
+ expect(XPath.match( @rexml, "//ART//GEN_PRODUCTION").size).to eq 2
259
261
  expect(XPath.match( @rexml, "//ART//GEN_PRODUCTION").first.text).to eq 'X'
260
262
  expect(XPath.match( @rexml, "//ART//INSULIN_CATEGORY").size).to eq 1
261
263
  expect(XPath.match( @rexml, "//ART//INSULIN_CATEGORY").first.text).to eq 'Insulinanalog: schnell wirkend'
262
264
  end
263
265
 
266
+ it 'should flag fridge drugs correctly' do
267
+ doc = REXML::Document.new IO.read(checkAndGetArticleXmlName)
268
+ checkAndGetArticleWithGTIN(doc, Oddb2xml::FRIDGE_GTIN)
269
+ expect(XPath.match( doc, "//COOL='1']").size).to eq 1
270
+ end
271
+
264
272
  it 'should have a correct drug information for 7680555610041' do
265
273
  expect(XPath.match( @rexml, "//ART/[BC='7680555610041']").size).to eq 1
266
274
  expect(XPath.match( @rexml, "//ART//DRUG_INDEX").size).to eq 1
@@ -285,19 +293,20 @@ describe Oddb2xml::Builder do
285
293
  @oddb_fi_product_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_fi_product.xml'))
286
294
  options = Oddb2xml::Options.new
287
295
  options.parser.parse!(['-o'])
288
- @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options.opts).run }
296
+ # @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options.opts).run }
297
+ Oddb2xml::Cli.new(options.opts).run
289
298
  end
290
299
 
291
300
  it 'should return produce a correct oddb_fi.xml' do
292
- File.exists?(@oddb_fi_xml).should eq true
301
+ expect(File.exists?(@oddb_fi_xml)).to eq true
293
302
  inhalt = IO.read(@oddb_fi_xml)
294
- /<KMP/.match(inhalt.to_s).to_s.should eq '<KMP'
295
- /<style><!\[CDATA\[p{margin-top/.match(inhalt.to_s).to_s.should eq '<style><![CDATA[p{margin-top'
303
+ expect(/<KMP/.match(inhalt.to_s).to_s).to eq '<KMP'
304
+ expect(/<style><!\[CDATA\[p{margin-top/.match(inhalt.to_s).to_s).to eq '<style><![CDATA[p{margin-top'
296
305
  m = /<paragraph><!\[CDATA\[(.+)\n(.*)/.match(inhalt.to_s)
297
- m[1].should eq '<?xml version="1.0" encoding="utf-8"?><div xmlns="http://www.w3.org/1999/xhtml">'
306
+ expect(m[1]).to eq '<?xml version="1.0" encoding="utf-8"?><div xmlns="http://www.w3.org/1999/xhtml">'
298
307
  expected = '<p class="s2"> </p>'
299
308
  skip { m[2].should eq '<p class="s4" id="section1"><span class="s2"><span>Zyvoxid</span></span><sup class="s3"><span>®</span></sup></p>' }
300
- File.exists?(@oddb_fi_product_xml).should eq true
309
+ expect(File.exists?(@oddb_fi_product_xml)).to eq true
301
310
  inhalt = IO.read(@oddb_fi_product_xml)
302
311
  end
303
312
 
@@ -308,7 +317,7 @@ if RUN_ALL
308
317
  end
309
318
 
310
319
  it 'should generate a valid oddb_product.xml' do
311
- @res.should match(/products/)
320
+ expect(@res).to match(/products/)
312
321
  checkProductXml
313
322
  end
314
323
  end
@@ -323,13 +332,13 @@ if RUN_ALL
323
332
  end
324
333
 
325
334
  it 'should contain the correct values fo CMUT from zurrose_transfer.dat' do
326
- @res.should match(/products/)
335
+ expect(@res).to match(/products/)
327
336
  dat_filename = File.join(Oddb2xml::WorkDir, 'oddb.dat')
328
- File.exists?(dat_filename).should eq true
337
+ expect(File.exists?(dat_filename)).to eq true
329
338
  oddb_dat = IO.read(dat_filename)
330
- oddb_dat.should match(/^..2/), "should have a record with '2' in CMUT field"
331
- oddb_dat.should match(/^..3/), "should have a record with '3' in CMUT field"
332
- oddb_dat.should match(RegExpDesitin), "should have Desitin"
339
+ expect(oddb_dat).to match(/^..2/), "should have a record with '2' in CMUT field"
340
+ expect(oddb_dat).to match(/^..3/), "should have a record with '3' in CMUT field"
341
+ expect(oddb_dat).to match(RegExpDesitin), "should have Desitin"
333
342
  IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line) }
334
343
  m = /.+DIAPHIN Trocke.*7680555610041.+/.match(oddb_dat)
335
344
  expect(m[0].size).to eq 97 # size of IGM 1 record
@@ -348,17 +357,17 @@ if RUN_ALL
348
357
 
349
358
  it 'should generate a valid oddb_with_migel.dat' do
350
359
  dat_filename = File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')
351
- File.exists?(dat_filename).should eq true
360
+ expect(File.exists?(dat_filename)).to eq true
352
361
  oddb_dat = IO.read(dat_filename)
353
- oddb_dat.should match(RegExpDesitin), "should have Desitin"
354
- @res.should match(/products/)
362
+ expect(oddb_dat).to match(RegExpDesitin), "should have Desitin"
363
+ expect(@res).to match(/products/)
355
364
  end
356
365
 
357
366
  it "should match EAN 76806206900842 of Desitin" do
358
367
  dat_filename = File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')
359
- File.exists?(dat_filename).should eq true
368
+ expect(File.exists?(dat_filename)).to eq true
360
369
  oddb_dat = IO.read(dat_filename)
361
- oddb_dat.should match(/76806206900842/), "should match EAN of Desitin"
370
+ expect(oddb_dat).to match(/76806206900842/), "should match EAN of Desitin"
362
371
  end
363
372
  end
364
373
 
@@ -380,7 +389,7 @@ if RUN_ALL
380
389
  end
381
390
 
382
391
  it 'should generate a valid oddb_product.xml' do
383
- @res.should match(/products/)
392
+ expect(@res).to match(/products/) if @res != nil
384
393
  checkProductXml
385
394
  end
386
395
 
@@ -413,17 +422,24 @@ if RUN_ALL
413
422
  end
414
423
 
415
424
  it 'should report correct output on stdout' do
416
- @res.should match(/\sPharma products: \d+/)
417
- @res.should match(/\sNonPharma products: \d+/)
425
+ expect(@res).to match(/\sPharma products: \d+/)
426
+ expect(@res).to match(/\sNonPharma products: \d+/)
418
427
  end if RUN_ALL
419
428
 
420
429
  it 'should contain the correct (normal) prices' do
421
430
  checkPrices(false)
422
431
  end
423
432
 
433
+ it 'should generate the flag ORPH for orphan' do
434
+ doc = REXML::Document.new File.new(checkAndGetArticleXmlName('non-refdata'))
435
+ orphan = checkAndGetArticleWithGTIN(doc, Oddb2xml::ORPHAN_GTIN)
436
+ expect(orphan).not_to eq nil
437
+ expect(orphan.elements['ORPH'].text).to eq("true")
438
+ end
439
+
424
440
  it 'should generate the flag non-refdata' do
425
441
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName('non-refdata'))
426
- XPath.match( doc, "//REF_DATA" ).size.should > 0
442
+ expect(XPath.match( doc, "//REF_DATA" ).size).to be > 0
427
443
  checkItemForRefdata(doc, "1699947", 1) # 3TC Filmtabl 150 mg SMNO 53662013 IKSNR 53‘662, 53‘663
428
444
  checkItemForRefdata(doc, "0598003", 0) # SOFRADEX Gtt Auric 8 ml
429
445
  checkItemForRefdata(doc, "5366964", 1) # 1-DAY ACUVUE moist jour
@@ -435,8 +451,8 @@ if RUN_ALL
435
451
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
436
452
  article = XPath.match( doc, "//ART[ARTINS/NINCD=13]").first
437
453
  article = XPath.match( doc, "//ART[PHAR=5366964]").first
438
- article.elements['SALECD'].text.should == 'A'
439
- article.elements['ARTINS/NINCD'].text.should == '13'
454
+ expect(article.elements['SALECD'].text).to eq('A')
455
+ expect(article.elements['ARTINS/NINCD'].text).to eq('13')
440
456
  end
441
457
 
442
458
  it 'should pass validating via oddb2xml.xsd' do
@@ -446,56 +462,56 @@ if RUN_ALL
446
462
  it 'should not contain veterinary iksnr 47066 CANIPHEDRIN' do
447
463
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
448
464
  dscrds = XPath.match( doc, "//ART" )
449
- XPath.match( doc, "//BC" ).find_all{|x| x.text.match('47066') }.size.should == 0
450
- XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/CANIPHEDRIN/) }.size.should == 0
465
+ expect(XPath.match( doc, "//BC" ).find_all{|x| x.text.match('47066') }.size).to eq(0)
466
+ expect(XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/CANIPHEDRIN/) }.size).to eq(0)
451
467
  end
452
468
 
453
469
  it 'should handle not duplicate pharmacode 5366964' do
454
470
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
455
471
  dscrds = XPath.match( doc, "//ART" )
456
- XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('5366964') }.size.should == 1
457
- dscrds.size.should == NrExtendedArticles
458
- XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should >= 1
459
- XPath.match( doc, "//PRODNO" ).find_all{|x| x.text.match('002771') }.size.should == 0
460
- XPath.match( doc, "//PRODNO" ).find_all{|x| x.text.match('620691') }.size.should == 1
472
+ expect(XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('5366964') }.size).to eq(1)
473
+ expect(dscrds.size).to eq(NrExtendedArticles)
474
+ expect(XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size).to be >= 1
475
+ expect(XPath.match( doc, "//PRODNO" ).find_all{|x| x.text.match('002771') }.size).to eq(0)
476
+ expect(XPath.match( doc, "//PRODNO" ).find_all{|x| x.text.match('620691') }.size).to eq(1)
461
477
  end
462
478
 
463
479
  it 'should load correct number of nonpharma' do
464
480
  doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
465
481
  dscrds = XPath.match( doc, "//ART" )
466
- dscrds.size.should == NrExtendedArticles
467
- XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('1699947') }.size.should == 1 # swissmedic_packages Cardio-Pulmo-Rénal Sérocytol, suppositoire
468
- XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('2465312') }.size.should == 1 # from refdata_pharma.xml"
469
- XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('0000000') }.size.should == 1 # from refdata_pharma.xml
482
+ expect(dscrds.size).to eq(NrExtendedArticles)
483
+ expect(XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('1699947') }.size).to eq(1) # swissmedic_packages Cardio-Pulmo-Rénal Sérocytol, suppositoire
484
+ expect(XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('2465312') }.size).to eq(1) # from refdata_pharma.xml"
485
+ expect(XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('0000000') }.size).to eq(1) # from refdata_pharma.xml
470
486
  end
471
487
 
472
488
  it 'should emit a correct oddb_limitation.xml' do
473
489
  # check limitations
474
490
  limitation_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_limitation.xml'))
475
- File.exists?(limitation_filename).should eq true
491
+ expect(File.exists?(limitation_filename)).to eq true
476
492
  doc = REXML::Document.new File.new(limitation_filename)
477
493
  limitations = XPath.match( doc, "//LIM" )
478
- limitations.size.should >= 4
479
- XPath.match( doc, "//SwissmedicNo5" ).find_all{|x| x.text.match('28486') }.size.should == 1
480
- XPath.match( doc, "//LIMNAMEBAG" ).find_all{|x| x.text.match('ZYVOXID') }.size.should == 1
481
- XPath.match( doc, "//LIMNAMEBAG" ).find_all{|x| x.text.match('070240') }.size.should == 1
482
- XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/^Gesamthaft zugelassen/) }.size.should == 1
483
- XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/^Behandlung nosokomialer Pneumonien/) }.size.should == 1
494
+ expect(limitations.size).to be >= 4
495
+ expect(XPath.match( doc, "//SwissmedicNo5" ).find_all{|x| x.text.match('28486') }.size).to eq(1)
496
+ expect(XPath.match( doc, "//LIMNAMEBAG" ).find_all{|x| x.text.match('ZYVOXID') }.size).to eq(1)
497
+ expect(XPath.match( doc, "//LIMNAMEBAG" ).find_all{|x| x.text.match('070240') }.size).to eq(1)
498
+ expect(XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/^Gesamthaft zugelassen/) }.size).to eq(1)
499
+ expect(XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/^Behandlung nosokomialer Pneumonien/) }.size).to eq(1)
484
500
  end
485
501
 
486
502
  it 'should emit a correct oddb_substance.xml' do
487
503
  doc = REXML::Document.new File.new(File.join(Oddb2xml::WorkDir, 'oddb_substance.xml'))
488
504
  names = XPath.match( doc, "//NAML" )
489
- names.size.should == NrSubstances
490
- names.find_all{|x| x.text.match('Lamivudinum') }.size.should == 1
505
+ expect(names.size).to eq(NrSubstances)
506
+ expect(names.find_all{|x| x.text.match('Lamivudinum') }.size).to eq(1)
491
507
  end
492
508
 
493
509
  it 'should emit a correct oddb_interaction.xml' do
494
510
  doc = REXML::Document.new File.new(File.join(Oddb2xml::WorkDir, 'oddb_interaction.xml'))
495
511
  titles = XPath.match( doc, "//TITD" )
496
- titles.size.should eq 5
497
- titles.find_all{|x| x.text.match('Keine Interaktion') }.size.should >= 1
498
- titles.find_all{|x| x.text.match('Erhöhtes Risiko für Myopathie und Rhabdomyolyse') }.size.should == 1
512
+ expect(titles.size).to eq 5
513
+ expect(titles.find_all{|x| x.text.match('Keine Interaktion') }.size).to be >= 1
514
+ expect(titles.find_all{|x| x.text.match('Erhöhtes Risiko für Myopathie und Rhabdomyolyse') }.size).to eq(1)
499
515
  end
500
516
 
501
517
  def checkItemForSALECD(doc, ean13, expected)
@@ -506,16 +522,16 @@ if RUN_ALL
506
522
  puts "checking doc for ean13 #{ean13} expected #{expected} == #{salecd}. #{name}"
507
523
  puts article.text
508
524
  end
509
- article.elements['SALECD'].text.should == expected.to_s
525
+ expect(article.elements['SALECD'].text).to eq(expected.to_s)
510
526
  end
511
527
 
512
528
  it 'should generate the flag SALECD' do
513
529
  @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
514
- File.exists?(@article_xml).should eq true
530
+ expect(File.exists?(@article_xml)).to eq true
515
531
  FileUtils.cp(@article_xml, File.join(Oddb2xml::WorkDir, 'tst-SALECD.xml'))
516
532
  article_xml = IO.read(@article_xml)
517
533
  doc = REXML::Document.new File.new(@article_xml)
518
- XPath.match( doc, "//REF_DATA" ).size.should > 0
534
+ expect(XPath.match( doc, "//REF_DATA" ).size).to be > 0
519
535
  checkItemForSALECD(doc, Oddb2xml::FERRO_GRADUMET_GTIN, 'A') # FERRO-GRADUMET Depottabl 30 Stk
520
536
  checkItemForSALECD(doc, Oddb2xml::SOFRADEX_GTIN, 'I') # SOFRADEX
521
537
  end
@@ -531,7 +547,7 @@ if RUN_ALL
531
547
 
532
548
  it 'should add 80 percent to zur_rose pubbprice' do
533
549
  @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
534
- File.exists?(@article_xml).should eq true
550
+ expect(File.exists?(@article_xml)).to eq true
535
551
  FileUtils.cp(@article_xml, File.join(Oddb2xml::WorkDir, 'tst-e80.xml'))
536
552
  checkProductXml
537
553
  checkArticleXml
@@ -541,6 +557,12 @@ if RUN_ALL
541
557
  it 'should generate a correct oddb_product.xml' do
542
558
  checkProductXml
543
559
  end
560
+
561
+ it 'should generate a product with the COOL (fridge) attribute' do
562
+ fridge_product = checkAndGetProductWithGTIN(doc, Oddb2xml::FRIDGE_GTIN)
563
+ fridge_product.elements['COOL'].text.should == '1'
564
+ end
565
+
544
566
  it 'should generate a correct oddb_article.xml' do
545
567
  checkArticleXml
546
568
  end
@@ -555,16 +577,16 @@ if RUN_ALL
555
577
  end
556
578
 
557
579
  it 'should report correct number of items' do
558
- @res.should match(/products/)
580
+ expect(@res).to match(/products/)
559
581
  end
560
582
 
561
583
  it 'should contain the correct values fo CMUT from zurrose_transfer.dat' do
562
584
  dat_filename = File.join(Oddb2xml::WorkDir, 'oddb.dat')
563
- File.exists?(dat_filename).should eq true
585
+ expect(File.exists?(dat_filename)).to eq true
564
586
  oddb_dat = IO.read(dat_filename)
565
- oddb_dat.should match(/^..2/), "should have a record with '2' in CMUT field"
566
- oddb_dat.should match(/^..3/), "should have a record with '3' in CMUT field"
567
- oddb_dat.should match(RegExpDesitin), "should have Desitin"
587
+ expect(oddb_dat).to match(/^..2/), "should have a record with '2' in CMUT field"
588
+ expect(oddb_dat).to match(/^..3/), "should have a record with '3' in CMUT field"
589
+ expect(oddb_dat).to match(RegExpDesitin), "should have Desitin"
568
590
  IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line) }
569
591
  # oddb_dat.should match(/^..1/), "should have a record with '1' in CMUT field" # we have no
570
592
  end
@@ -579,12 +601,12 @@ if RUN_ALL
579
601
  end
580
602
 
581
603
  it 'should report correct number of items' do
582
- @res.should match(/products/)
604
+ expect(@res).to match(/products/)
583
605
  end
584
606
 
585
607
  it 'should contain the corect prices' do
586
608
  dat_filename = File.join(Oddb2xml::WorkDir, 'oddb.dat')
587
- File.exists?(dat_filename).should eq true
609
+ expect(File.exists?(dat_filename)).to eq true
588
610
  oddb_dat = IO.read(dat_filename)
589
611
  oddb_dat_lines = IO.readlines(dat_filename)
590
612
  IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 883, true) }