oddb2xml 2.1.7 → 2.1.8

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.
@@ -2,16 +2,111 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require "#{Dir.pwd}/lib/oddb2xml/downloader"
5
+ ENV['TZ'] = 'UTC' # needed for last_change
5
6
 
6
- describe Oddb2xml::Extractor do
7
- it "pending"
7
+ describe Oddb2xml::BMUpdateExtractor do
8
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
9
+ after(:all) { VCR.eject_cassette }
10
+ before(:all) {
11
+ VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
12
+ @downloader = Oddb2xml::BMUpdateDownloader.new
13
+ xml = @downloader.download
14
+ @items = Oddb2xml::BMUpdateExtractor.new(xml).to_hash
15
+ }
16
+ it "should have at least one item" do
17
+ expect(@items.size).not_to eq 0
18
+ end
8
19
  end
9
20
 
10
- describe Oddb2xml::TxtExtractorMethods do
11
- it "pending"
21
+ describe Oddb2xml::LppvExtractor do
22
+ before(:all) {
23
+ VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
24
+ @downloader = Oddb2xml::LppvDownloader.new
25
+ @content = @downloader.download
26
+ @lppvs = Oddb2xml::LppvExtractor.new(@content).to_hash
27
+ }
28
+ after(:all) { VCR.eject_cassette }
29
+ it "should have at least one item" do
30
+ expect(@lppvs.size).not_to eq 0
31
+ end
32
+ end
33
+
34
+ describe Oddb2xml::MigelExtractor do
35
+ before(:all) {
36
+ VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
37
+ @downloader = Oddb2xml::MigelDownloader.new
38
+ xml = @downloader.download
39
+ @items = Oddb2xml::MigelExtractor.new(xml).to_hash
40
+ }
41
+ after(:all) { VCR.eject_cassette }
42
+ it "should have at some items" do
43
+ expect(@items.size).not_to eq 0
44
+ expect(@items.find{|k,v| /3248410/i.match(v[:pharmacode]) }).not_to be_nil
45
+ expect(@items.find{|k,v| /Novopen/i.match(v[:desc_de]) }).not_to be_nil
46
+ expect(@items.find{|k,v| /3036984/i.match(v[:pharmacode]) }).not_to be_nil
47
+ end
48
+ end
49
+
50
+ describe Oddb2xml::RefdataExtractor do
51
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
52
+ after(:all) { VCR.eject_cassette }
53
+ context 'should handle pharma articles' do
54
+ subject do
55
+ @downloader = Oddb2xml::RefdataDownloader.new({}, :pharma)
56
+ xml = @downloader.download
57
+ @pharma_items = Oddb2xml::RefdataExtractor.new(xml, 'PHARMA').to_hash
58
+ end
59
+
60
+ it "should have correct info for pharmacode 1699947 correctly" do
61
+ @pharma_items = subject.to_hash
62
+ pharma_code_LEVETIRACETAM = "5819012"
63
+ item_found = @pharma_items.values.find{ |x| x[:pharmacode].eql?(pharma_code_LEVETIRACETAM)}
64
+ expect(item_found).not_to be nil
65
+ expected = { :refdata=>true,
66
+ :_type=>:pharma,
67
+ :ean=> Oddb2xml::LEVETIRACETAM_GTIN,
68
+ :pharmacode=> pharma_code_LEVETIRACETAM,
69
+ :last_change => "2015-06-04 00:00:00 +0000",
70
+ :desc_de=>"LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk",
71
+ :desc_fr=>"LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce",
72
+ :atc_code=>"N03AX14",
73
+ :company_name=>"Desitin Pharma GmbH",
74
+ :company_ean=>"7601001320451"}
75
+ expect(item_found).to eq(expected)
76
+ expect(@pharma_items.size).to eq(15)
77
+ end
78
+ end
79
+ context 'should handle nonpharma articles' do
80
+ subject do
81
+ @downloader = Oddb2xml::RefdataDownloader.new({}, :nonpharma)
82
+ xml = @downloader.download
83
+ @non_pharma_items = Oddb2xml::RefdataExtractor.new(xml, :non_pharma).to_hash
84
+ end
85
+
86
+ it "should have correct info for nonpharma with pharmacode 0058502 correctly" do
87
+ @non_pharma_items = subject.to_hash
88
+ pharma_code_TUBEGAZE = '0058519'
89
+ item_found = @non_pharma_items.values.find{ |x| x[:pharmacode].eql?(pharma_code_TUBEGAZE)}
90
+ expect(item_found).not_to be nil
91
+ expected = {:refdata=>true,
92
+ :_type=>:nonpharma,
93
+ :ean=>"7611600441020",
94
+ :pharmacode=>pharma_code_TUBEGAZE,
95
+ :last_change => "2015-06-04 00:00:00 +0000",
96
+ :desc_de=>"TUBEGAZE Verband weiss Nr 12 20m Finger gross",
97
+ :desc_fr=>"TUBEGAZE pans tubul blanc Nr 12 20m doigts grands",
98
+ :atc_code=>"",
99
+ :company_name=>"IVF HARTMANN AG",
100
+ :company_ean=>"7601001000896"}
101
+ expect(item_found).to eq(expected)
102
+ expect(@non_pharma_items.size).to eq(9)
103
+ end
104
+ end
12
105
  end
13
106
 
14
107
  describe Oddb2xml::BagXmlExtractor do
108
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
109
+ after(:all) { VCR.eject_cassette }
15
110
  context 'should handle articles with and without pharmacode' do
16
111
  subject do
17
112
  dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
@@ -41,78 +136,60 @@ describe Oddb2xml::BagXmlExtractor do
41
136
  end
42
137
  end
43
138
 
44
- describe Oddb2xml::SwissIndexExtractor do
45
- it "pending"
46
- end
47
-
48
- describe Oddb2xml::BMUpdateExtractor do
49
- it "pending"
50
- end
51
-
52
- describe Oddb2xml::LppvExtractor do
53
- it "pending"
54
- end
55
-
56
- describe Oddb2xml::SwissIndexExtractor do
57
- it "pending"
58
- end
59
-
60
- describe Oddb2xml::MigelExtractor do
61
- it "pending"
62
- end
63
-
64
139
  describe Oddb2xml::SwissmedicInfoExtractor do
140
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
141
+ after(:all) { VCR.eject_cassette }
65
142
  include ServerMockHelper
66
143
  before(:each) do
67
- setup_swissmedic_info_server_mock
68
144
  @downloader = Oddb2xml::SwissmedicInfoDownloader.new
69
145
  end
70
146
  context 'builds fachfinfo' do
71
147
  it {
72
148
  xml = @downloader.download
73
149
  @infos = Oddb2xml::SwissmedicInfoExtractor.new(xml).to_hash
74
- expect(@infos.size).to eq(1)
75
- erbiumcitrat = nil
150
+ expect(@infos.keys).to eq ['de', 'fr']
151
+ expect(@infos['de'].size).to eq 5
152
+ expect(@infos['fr'].size).to eq 2
153
+ levetiracetam = nil
76
154
  @infos['de'].each{|info|
77
- erbiumcitrat = info if /Erbiumcitrat/.match(info[:name])
155
+ levetiracetam = info if /Levetiracetam/.match(info[:name])
78
156
  }
79
- expect(erbiumcitrat[:owner]).to eq('CBI Medical Products Vertriebs GmbH')
80
- expect(erbiumcitrat[:paragraph].to_s).to match(/Packungen/)
81
- expect(erbiumcitrat[:paragraph].to_s).to match(/Stand der Information/)
82
- expect(erbiumcitrat[:paragraph].to_s).to match(/Zulassungsinhaberin/)
157
+ expect(levetiracetam[:owner]).to eq('Desitin Pharma GmbH')
158
+ expect(levetiracetam[:paragraph].to_s).to match(/Packungen/)
159
+ expect(levetiracetam[:paragraph].to_s).to match(/Zulassungsinhaberin/)
83
160
  }
84
161
  end
85
162
  end
86
163
 
87
164
  describe Oddb2xml::SwissmedicExtractor do
88
- before(:each) do
89
- setup_epha_atc_csv_mock
90
- end
165
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
166
+ after(:all) { VCR.eject_cassette }
91
167
  context 'when transfer.dat is empty' do
92
168
  subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
93
169
  it { expect(subject.to_hash).to be_empty }
94
170
  end
95
171
  context 'can parse swissmedic_package.xlsx' do
96
172
  it {
173
+ cleanup_directories_before_run
97
174
  filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
98
175
  @packs = Oddb2xml::SwissmedicExtractor.new(filename, :package).to_hash
99
176
  expect(@packs.size).to eq(17)
100
177
  serocytol = nil
101
178
  @packs.each{|pack|
102
- serocytol = pack[1] if pack[0].to_s == '00274001'
179
+ serocytol = pack[1] if pack[1][:ean] == '7680620690084'
103
180
  }
104
- expect(serocytol[:atc_code]).to eq('J06AA')
181
+ expect(serocytol[:atc_code]).to eq('N03AX14')
105
182
  expect(serocytol[:swissmedic_category]).to eq('B')
106
- expect(serocytol[:package_size]).to eq('3')
107
- expect(serocytol[:einheit_swissmedic]).to eq('Suppositorien')
108
- expect(serocytol[:substance_swissmedic]).to eq('globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)')
183
+ expect(serocytol[:package_size]).to eq('30')
184
+ expect(serocytol[:einheit_swissmedic]).to eq('Tablette(n)')
185
+ expect(serocytol[:substance_swissmedic]).to eq('levetiracetamum')
109
186
  }
110
187
  end
111
188
  context 'can parse swissmedic_fridge.xlsx' do
112
189
  it {
113
190
  filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
114
191
  @packs = Oddb2xml::SwissmedicExtractor.new(filename, :fridge).to_arry
115
- expect(@packs.size).to eq(17)
192
+ expect(@packs.size >= 17).to eq true
116
193
  expect(@packs[0]).to eq("58618")
117
194
  expect(@packs[1]).to eq("00696")
118
195
  }
@@ -122,7 +199,7 @@ describe Oddb2xml::SwissmedicExtractor do
122
199
  filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
123
200
  expect(File.exists?(filename)).to eq(true), "File #{filename} must exists"
124
201
  @packs = Oddb2xml::SwissmedicExtractor.new(filename, :orphan).to_arry
125
- expect(@packs.size).to eq(78)
202
+ expect(@packs.size >= 78).to eq true
126
203
  expect(@packs.first).to eq("62132")
127
204
  expect(@packs[7]).to eq("00687")
128
205
  }
@@ -130,6 +207,8 @@ describe Oddb2xml::SwissmedicExtractor do
130
207
  end
131
208
 
132
209
  describe Oddb2xml::EphaExtractor do
210
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
211
+ after(:all) { VCR.eject_cassette }
133
212
  context 'can parse epha_interactions.csv' do
134
213
  it {
135
214
  filename = File.join(Oddb2xml::SpecData, 'epha_interactions.csv')
@@ -141,10 +220,14 @@ describe Oddb2xml::EphaExtractor do
141
220
  end
142
221
 
143
222
  describe Oddb2xml::MedregbmExtractor do
223
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
224
+ after(:all) { VCR.eject_cassette }
144
225
  it "pending"
145
226
  end
146
227
 
147
228
  describe Oddb2xml::ZurroseExtractor do
229
+ before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
230
+ after(:all) { VCR.eject_cassette }
148
231
  context 'when transfer.dat is empty' do
149
232
  subject { Oddb2xml::ZurroseExtractor.new("") }
150
233
  it { expect(subject.to_hash).to be_empty }
@@ -180,7 +263,6 @@ describe Oddb2xml::ZurroseExtractor do
180
263
  DAT
181
264
  Oddb2xml::ZurroseExtractor.new(dat)
182
265
  end
183
- #it { expect(pp subject.to_hash) }
184
266
  it { expect(subject.to_hash.keys.length).to eq(1) }
185
267
  it { expect(subject.to_hash.keys.first).to eq("7680284070840") }
186
268
  it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
@@ -248,4 +330,4 @@ describe Oddb2xml::ZurroseExtractor do
248
330
 
249
331
  end
250
332
 
251
- end
333
+ end