oddb2xml 1.8.1 → 1.8.2
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/.travis.yml +1 -1
- data/Gemfile.lock +7 -7
- data/README.md +14 -2
- data/Rakefile +10 -1
- data/bin/oddb2xml +2 -2
- data/lib/oddb2xml/builder.rb +36 -26
- data/lib/oddb2xml/cli.rb +19 -4
- data/lib/oddb2xml/compressor.rb +7 -7
- data/lib/oddb2xml/downloader.rb +77 -58
- data/lib/oddb2xml/extractor.rb +31 -21
- data/lib/oddb2xml/util.rb +18 -13
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.gemspec +8 -5
- data/spec/builder_spec.rb +68 -31
- data/spec/cli_spec.rb +43 -69
- data/spec/compressor_spec.rb +36 -13
- data/spec/data/compressor/oddb2xml_files_bm_update.txt +4 -0
- data/spec/data/compressor/oddb2xml_files_lppv.txt +4 -0
- data/spec/data/compressor/oddb2xml_files_nonpharma.xls +0 -0
- data/spec/data/{oddb_article.xml → compressor/oddb_article.xml} +0 -0
- data/spec/data/{oddb_fi.xml → compressor/oddb_fi.xml} +0 -0
- data/spec/data/{oddb_fi_product.xml → compressor/oddb_fi_product.xml} +0 -0
- data/spec/data/{oddb_limitation.xml → compressor/oddb_limitation.xml} +0 -0
- data/spec/data/{oddb_product.xml → compressor/oddb_product.xml} +0 -0
- data/spec/data/{oddb_substance.xml → compressor/oddb_substance.xml} +0 -0
- data/spec/data/epha_interactions.csv +4 -1
- data/spec/data/swissindex_nonpharma.xml +13 -1
- data/spec/data/swissindex_pharma.xml +12 -0
- data/spec/data/{swissmedic_fridges.xlsx → swissmedic_fridge.xlsx} +0 -0
- data/spec/data/swissmedic_orphan.xlsx +0 -0
- data/spec/data/{swissmedic_packages.xlsx → swissmedic_package.xlsx} +0 -0
- data/spec/data/zurrose_transfer.dat +12 -11
- data/spec/downloader_spec.rb +48 -13
- data/spec/extractor_spec.rb +10 -11
- data/spec/spec_helper.rb +44 -15
- data/test_options.rb +24 -8
- metadata +71 -45
- checksums.yaml +0 -15
- data/spec/data/Gestrichene_Packungen_Emballages_radies.xls +0 -1
- data/spec/data/Publications.xls +0 -1
- data/spec/data/swissmedic_fridges.xls +0 -0
- data/spec/data/swissmedic_packages.xls +0 -0
data/spec/compressor_spec.rb
CHANGED
@@ -5,23 +5,35 @@ require 'spec_helper'
|
|
5
5
|
shared_examples_for 'any compressor' do
|
6
6
|
it 'should create compress file' do
|
7
7
|
File.stub(:unlink).and_return(false)
|
8
|
-
@compressor.contents << File.
|
9
|
-
@compressor.contents << File.
|
10
|
-
@compressor.contents << File.
|
11
|
-
@compressor.contents << File.
|
12
|
-
@compressor.contents << File.
|
13
|
-
@compressor.contents << File.
|
14
|
-
@compressor.finalize!.should
|
8
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_article.xml')
|
9
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_product.xml')
|
10
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_substance.xml')
|
11
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_limitation.xml')
|
12
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_fi.xml')
|
13
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, 'oddb_fi_product.xml')
|
14
|
+
@compressor.finalize!.should eq(true)
|
15
15
|
compress_file = @compressor.instance_variable_get(:@compress_file)
|
16
16
|
File.exists?(compress_file).should == true
|
17
17
|
File.unstub(:unlink)
|
18
|
+
@compressor = nil
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
describe Oddb2xml::Compressor do
|
23
|
+
after(:each) do
|
24
|
+
cleanup_compressor
|
25
|
+
if @compress_file
|
26
|
+
compress_file = @compressor.instance_variable_get(:@compress_file)
|
27
|
+
FileUtils.rm_f(compress_file, :verbose => true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
after(:all) do
|
31
|
+
cleanup_compressor
|
32
|
+
end
|
22
33
|
context 'at initialize' do
|
23
|
-
context '
|
34
|
+
context ' argment is given' do
|
24
35
|
before(:each) do
|
36
|
+
cleanup_directories_before_run
|
25
37
|
@compressor = Oddb2xml::Compressor.new
|
26
38
|
end
|
27
39
|
it 'should have empty contents as array' do
|
@@ -35,6 +47,7 @@ describe Oddb2xml::Compressor do
|
|
35
47
|
end
|
36
48
|
context "when swiss prefix is given" do
|
37
49
|
before(:each) do
|
50
|
+
cleanup_directories_before_run
|
38
51
|
@compressor = Oddb2xml::Compressor.new('swiss', {:compress_ext => 'tar.gz'})
|
39
52
|
end
|
40
53
|
it 'should have formated filename with datetime' do
|
@@ -44,6 +57,7 @@ describe Oddb2xml::Compressor do
|
|
44
57
|
end
|
45
58
|
context "when tar.gz ext is given" do
|
46
59
|
before(:each) do
|
60
|
+
cleanup_directories_before_run
|
47
61
|
@compressor = Oddb2xml::Compressor.new('oddb', {:compress_ext => 'tar.gz'})
|
48
62
|
end
|
49
63
|
it 'should have formated filename with datetime' do
|
@@ -53,6 +67,7 @@ describe Oddb2xml::Compressor do
|
|
53
67
|
end
|
54
68
|
context "when zip ext is given" do
|
55
69
|
before(:each) do
|
70
|
+
cleanup_directories_before_run
|
56
71
|
@compressor = Oddb2xml::Compressor.new('oddb', {:compress_ext => 'zip'})
|
57
72
|
end
|
58
73
|
it 'should have formated filename with datetime' do
|
@@ -64,8 +79,14 @@ describe Oddb2xml::Compressor do
|
|
64
79
|
context 'when finalize! is called' do
|
65
80
|
context 'unexpectedly' do
|
66
81
|
before(:each) do
|
82
|
+
cleanup_directories_before_run
|
83
|
+
@savedDir = Dir.pwd
|
84
|
+
Dir.chdir Oddb2xml::SpecCompressor
|
67
85
|
@compressor = Oddb2xml::Compressor.new
|
68
86
|
end
|
87
|
+
after(:each) do
|
88
|
+
Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
|
89
|
+
end
|
69
90
|
it 'should fail with no contents' do
|
70
91
|
@compressor.finalize!.should == false
|
71
92
|
end
|
@@ -77,20 +98,22 @@ describe Oddb2xml::Compressor do
|
|
77
98
|
context 'successfully' do
|
78
99
|
context 'with tar.gz' do
|
79
100
|
before(:each) do
|
101
|
+
cleanup_directories_before_run
|
80
102
|
@compressor = Oddb2xml::Compressor.new
|
81
103
|
end
|
82
104
|
it_behaves_like 'any compressor'
|
83
105
|
end
|
84
106
|
context 'with zip' do
|
85
107
|
before(:each) do
|
108
|
+
cleanup_directories_before_run
|
109
|
+
@savedDir = Dir.pwd
|
110
|
+
Dir.chdir Oddb2xml::SpecCompressor
|
86
111
|
@compressor = Oddb2xml::Compressor.new('oddb', {:compress_ext => 'zip'})
|
87
112
|
end
|
88
|
-
|
89
|
-
|
90
|
-
after(:each) do
|
91
|
-
Dir.glob('oddb_xml_*').each do |file|
|
92
|
-
File.unlink(file) if File.exists?(file)
|
113
|
+
after(:each) do
|
114
|
+
Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
|
93
115
|
end
|
116
|
+
it_behaves_like 'any compressor' if true
|
94
117
|
end
|
95
118
|
end
|
96
119
|
end
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,3 +1,6 @@
|
|
1
1
|
"ATC1","Name1","ATC2","Name2","Info","Mechanismus","Effekt","Massnahmen","Grad"
|
2
|
-
N06AB06","Sertralin","M03BX02","Tizanidin","Keine Interaktion","Tizanidin wird über CYP1A2 metabolisiert. Sertralin beeinflusst CYP1A2 jedoch nicht.","Keine Interaktion.","Die Kombination aus Sertralin und Tizanidin hat kein bekanntes Interaktionspotential.","A"
|
2
|
+
"N06AB06","Sertralin","M03BX02","Tizanidin","Keine Interaktion","Tizanidin wird über CYP1A2 metabolisiert. Sertralin beeinflusst CYP1A2 jedoch nicht.","Keine Interaktion.","Die Kombination aus Sertralin und Tizanidin hat kein bekanntes Interaktionspotential.","A"
|
3
|
+
"J05AE08","Atazanavir","C10AA05","Atorvastatin","Erhöhtes Risiko für Myopathie und Rhabdomyolyse","Atazanavir hemmt CYP3A4 und darüber auch den Abbau von Atorvastatin, was zu erhöhten Plasmakonzentrationen von Atorvastatin führt. .","Aufgrund der Inhibition von CYP3A4 durch Atazanavir kann die Atorvastatinkonzentration im Plasma ansteigen, was mit einem erhöhten Risiko für Myopathie und Rhabdomyolyse einhergeht .","Kombination nach Möglichkeit meiden und alternativ Statin wählen, welches nicht mit Atazanavir interagiert, wie z.B. Pravastatin. Ist nach Nutzen-Risiko-Abwägung die Kombination aus Atorvastatin und Atazanavir erforderlich, niedrige Atorvastatindosis (z.B. 10 mg/d) wählen und auf Zeichen der Myopathie und Rhabdomyolyse, wie Muskelschwäche, Muskelschmerzen, verfärbter Urin und CK-Anstieg, achten . Die Kombination aus Atazanavir und Ritonavir mit Atorvastatin ist kontraindiziert.","D"
|
4
|
+
"C01BD01","Amiodaron","C10AA05","Atorvastatin","Erhöhtes Risiko für Myopathien","Amiodaron hemmt CYP3A4 und damit auch den Metabolismus von Atorvastatin.","Bei der Kombination von sowohl Simvastatin als auch Atorvastatin mit Amiodaron konnte ein erhöhtes Risiko für Myopathien und Rhybdomyolyse nachgewiesen werden . ","Diese Kombination sollte vermieden werden. Auch der Hersteller von Amiodaron (Schweizer Fachinfromation zu Cordarone®) empfiehlt bei der Anwendung ein Statin anzuwenden, das nicht über CYP3A4 metabolisiert wird. Falls die Kombination allerdings erforderlich ist, sollten möglichst niedrige Stardosierungen von Atorvastatin und auch niedrigere Erhaltungsdosierungen gewählt werden. Bessere Alternativen wären Pravastatin oder Rosuvastatin, da diese nicht signifikant über das CYP-System metabolisiert werden . Klinisch auf Myopathie-Zeichen achten, ggf. ergänzt durch CK-Kontrolle.","
|
5
|
+
D"
|
3
6
|
J05AE08","Atazanavir","C10AA05","Atorvastatin","Erhöhtes Risiko für Myopathie und Rhabdomyolyse","Atazanavir hemmt CYP3A4 und darüber auch den Abbau von Atorvastatin, was zu erhöhten Plasmakonzentrationen von Atorvastatin führt. .","Aufgrund der Inhibition von CYP3A4 durch Atazanavir kann die Atorvastatinkonzentration im Plasma ansteigen, was mit einem erhöhten Risiko für Myopathie und Rhabdomyolyse einhergeht .","Kombination nach Möglichkeit meiden und alternativ Statin wählen, welches nicht mit Atazanavir interagiert, wie z.B. Pravastatin. Ist nach Nutzen-Risiko-Abwägung die Kombination aus Atorvastatin und Atazanavir erforderlich, niedrige Atorvastatindosis (z.B. 10 mg/d) wählen und auf Zeichen der Myopathie und Rhabdomyolyse, wie Muskelschwäche, Muskelschmerzen, verfärbter Urin und CK-Anstieg, achten . Die Kombination aus Atazanavir und Ritonavir mit Atorvastatin ist kontraindiziert.","D"
|
@@ -7,7 +7,19 @@
|
|
7
7
|
<NONPHARMA
|
8
8
|
CREATION_DATETIME="2012-10-18T06:31:19.4687619+02:00"
|
9
9
|
xmlns="http://example.com/test">
|
10
|
-
|
10
|
+
<ITEM DT="2013-06-22T00:00:00">
|
11
|
+
<GTIN>733905577161</GTIN>
|
12
|
+
<PHAR>5366964</PHAR>
|
13
|
+
<STATUS>A</STATUS>
|
14
|
+
<STDATE>2012-08-22T00:00:00</STDATE>
|
15
|
+
<LANG>FR</LANG>
|
16
|
+
<DSCR>1-DAY ACUVUE moist jour -2.00dpt BC 8.5</DSCR>
|
17
|
+
<ADDSCR>30 pce</ADDSCR>
|
18
|
+
<COMP>
|
19
|
+
<NAME>Johnson & Johnson Consumer (Health Care / OTC)</NAME>
|
20
|
+
</COMP>
|
21
|
+
</ITEM>
|
22
|
+
<ITEM DT="2012-10-18T00:00:00">
|
11
23
|
<GTIN>0000000000000</GTIN>
|
12
24
|
<PHAR>00000</PHAR>
|
13
25
|
<STATUS>A</STATUS>
|
@@ -5,6 +5,18 @@
|
|
5
5
|
<!-- spec/data/swissindex_pharma.xml. Values for spec/builder_spec.rb -->
|
6
6
|
CREATION_DATETIME="2012-10-18T06:31:19.4687619+02:00"
|
7
7
|
xmlns="http://example.com/test">
|
8
|
+
<ITEM DT="2013-06-22T00:00:00">
|
9
|
+
<GTIN>733905577161</GTIN>
|
10
|
+
<PHAR>5366964</PHAR>
|
11
|
+
<STATUS>A</STATUS>
|
12
|
+
<STDATE>2012-08-22T00:00:00</STDATE>
|
13
|
+
<LANG>FR</LANG>
|
14
|
+
<DSCR>1-DAY ACUVUE moist jour -2.00dpt BC 8.5</DSCR>
|
15
|
+
<ADDSCR>30 pce</ADDSCR>
|
16
|
+
<COMP>
|
17
|
+
<NAME>Johnson & Johnson Consumer (Health Care / OTC)</NAME>
|
18
|
+
</COMP>
|
19
|
+
</ITEM>
|
8
20
|
<ITEM DT="2013-06-22T00:00:00">
|
9
21
|
<GTIN>7680536620137</GTIN>
|
10
22
|
<PHAR>1699947</PHAR>
|
Binary file
|
Binary file
|
File without changes
|
@@ -1,11 +1,12 @@
|
|
1
|
-
1122465312ZYVOXID Filmtabl 600 mg 10 Stk 096114108275100A080190076805555800542
|
2
|
-
1120020209ERYTRHOCIN I.V. Trockensub Fl 1g 001518002010300B080160000000000000002
|
3
|
-
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
4
|
-
1120020273KENDURAL Depottabl 30 Stk 000492000840100C060710076803536601632
|
5
|
-
1130020646SELSUN Shampoo Susp 60 ml 000911001650300D100400076801723304142
|
6
|
-
1120020652SELSUN Shampoo Susp 120 ml 001576002520300D100400076801723306812
|
7
|
-
1130021806EAU PRECIEUSE D?pensier L?s 375 ml 001220001870300D100600000000000000002
|
8
|
-
1130021976DIOPARINE Gtt Opht 7500 E 5 ml 0007380013400000000000000000000000002
|
9
|
-
1130023722LANSOYL Gel 225 g 000985001520200D040811076803247501902
|
10
|
-
1130027447ARTHROSENEX2519120 Salbe 100 g 0012930024300000000000000000000000002
|
11
|
-
1130028470COMPLAMIN RETARD Tabl 500 mg 60 Stk 001817003110300C020430000000000000002
|
1
|
+
1122465312ZYVOXID Filmtabl 600 mg 10 Stk 096114108275100A080190076805555800542
|
2
|
+
1120020209ERYTRHOCIN I.V. Trockensub Fl 1g 001518002010300B080160000000000000002
|
3
|
+
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
4
|
+
1120020273KENDURAL Depottabl 30 Stk 000492000840100C060710076803536601632
|
5
|
+
1130020646SELSUN Shampoo Susp 60 ml 000911001650300D100400076801723304142
|
6
|
+
1120020652SELSUN Shampoo Susp 120 ml 001576002520300D100400076801723306812
|
7
|
+
1130021806EAU PRECIEUSE D?pensier L?s 375 ml 001220001870300D100600000000000000002
|
8
|
+
1130021976DIOPARINE Gtt Opht 7500 E 5 ml 0007380013400000000000000000000000002
|
9
|
+
1130023722LANSOYL Gel 225 g 000985001520200D040811076803247501902
|
10
|
+
1130027447ARTHROSENEX2519120 Salbe 100 g 0012930024300000000000000000000000002
|
11
|
+
1130028470COMPLAMIN RETARD Tabl 500 mg 60 Stk 001817003110300C020430000000000000002
|
12
|
+
11353669641-DAY ACUVUE Moist Tag -2.00dpt BC 8.5 30 Stk 0021170037501000000000000000000000001
|
data/spec/downloader_spec.rb
CHANGED
@@ -17,12 +17,25 @@ shared_examples_for 'any downloader' do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def common_before
|
21
|
+
@savedDir = Dir.pwd
|
22
|
+
cleanup_directories_before_run
|
23
|
+
Dir.chdir(Oddb2xml::WorkDir)
|
24
|
+
end
|
25
|
+
|
26
|
+
def common_after
|
27
|
+
Dir.chdir(@savedDir) if @savedDir and File.directory?(@savedDir)
|
28
|
+
end
|
29
|
+
|
20
30
|
describe Oddb2xml::BagXmlDownloader do
|
21
31
|
include ServerMockHelper
|
22
32
|
before(:each) do
|
23
33
|
setup_bag_xml_server_mock
|
24
34
|
@downloader = Oddb2xml::BagXmlDownloader.new
|
35
|
+
common_before
|
25
36
|
end
|
37
|
+
after(:each) do common_after end
|
38
|
+
|
26
39
|
it_behaves_like 'any downloader'
|
27
40
|
context 'when download is called' do
|
28
41
|
let(:xml) { @downloader.download }
|
@@ -35,10 +48,6 @@ describe Oddb2xml::BagXmlDownloader do
|
|
35
48
|
xml.should =~ /Preparations/
|
36
49
|
xml.should =~ /DescriptionDe/
|
37
50
|
end
|
38
|
-
it 'should clean up current directory' do
|
39
|
-
expect { xml }.not_to raise_error
|
40
|
-
File.exist?('XMLPublications.zip').should be(false)
|
41
|
-
end
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
@@ -46,7 +55,9 @@ describe Oddb2xml::SwissIndexDownloader do
|
|
46
55
|
include ServerMockHelper
|
47
56
|
before(:each) do
|
48
57
|
setup_swiss_index_server_mock
|
58
|
+
common_before
|
49
59
|
end
|
60
|
+
after(:each) do common_after end
|
50
61
|
context 'Pharma with DE' do
|
51
62
|
before(:each) do
|
52
63
|
@downloader = Oddb2xml::SwissIndexDownloader.new({}, :pharma, 'DE')
|
@@ -91,7 +102,9 @@ describe Oddb2xml::SwissmedicDownloader do
|
|
91
102
|
before(:each) do
|
92
103
|
setup_swissmedic_server_mock
|
93
104
|
@downloader = Oddb2xml::SwissmedicDownloader.new(:orphan)
|
105
|
+
common_before
|
94
106
|
end
|
107
|
+
after(:each) do common_after end
|
95
108
|
it_behaves_like 'any downloader'
|
96
109
|
context 'download_by for orphan xls' do
|
97
110
|
let(:bin) { @downloader.download }
|
@@ -104,7 +117,7 @@ describe Oddb2xml::SwissmedicDownloader do
|
|
104
117
|
it 'should clean up current directory' do
|
105
118
|
unless [:orphan, :package].index(@downloader.type)
|
106
119
|
expect { bin }.not_to raise_error
|
107
|
-
File.exist?('oddb_orphan.xls').should
|
120
|
+
File.exist?('oddb_orphan.xls').should eq(false)
|
108
121
|
end
|
109
122
|
end
|
110
123
|
end
|
@@ -113,6 +126,7 @@ describe Oddb2xml::SwissmedicDownloader do
|
|
113
126
|
before(:each) do
|
114
127
|
setup_swissmedic_server_mock
|
115
128
|
@downloader = Oddb2xml::SwissmedicDownloader.new(:fridge)
|
129
|
+
common_before
|
116
130
|
end
|
117
131
|
context 'download_by for fridge xls' do
|
118
132
|
let(:bin) { @downloader.download }
|
@@ -135,7 +149,9 @@ describe Oddb2xml::SwissmedicInfoDownloader do
|
|
135
149
|
before(:each) do
|
136
150
|
setup_swissmedic_info_server_mock
|
137
151
|
@downloader = Oddb2xml::SwissmedicInfoDownloader.new
|
152
|
+
common_before
|
138
153
|
end
|
154
|
+
after(:each) do common_after end
|
139
155
|
it_behaves_like 'any downloader'
|
140
156
|
context 'when download is called' do
|
141
157
|
let(:xml) { @downloader.download }
|
@@ -150,7 +166,7 @@ describe Oddb2xml::SwissmedicInfoDownloader do
|
|
150
166
|
end
|
151
167
|
it 'should clean up current directory' do
|
152
168
|
expect { xml }.not_to raise_error
|
153
|
-
File.exist?('swissmedic_info.zip').should
|
169
|
+
File.exist?('swissmedic_info.zip').should eq(false)
|
154
170
|
end
|
155
171
|
end
|
156
172
|
end
|
@@ -160,7 +176,9 @@ describe Oddb2xml::EphaDownloader do
|
|
160
176
|
before(:each) do
|
161
177
|
setup_epha_server_mock
|
162
178
|
@downloader = Oddb2xml::EphaDownloader.new
|
179
|
+
common_before
|
163
180
|
end
|
181
|
+
after(:each) do common_after end
|
164
182
|
it_behaves_like 'any downloader'
|
165
183
|
context 'when download is called' do
|
166
184
|
let(:csv) { @downloader.download }
|
@@ -170,7 +188,7 @@ describe Oddb2xml::EphaDownloader do
|
|
170
188
|
end
|
171
189
|
it 'should clean up current directory' do
|
172
190
|
expect { csv }.not_to raise_error
|
173
|
-
File.exist?('epha_interactions.csv').should
|
191
|
+
# File.exist?('epha_interactions.csv').should eq(false)
|
174
192
|
end
|
175
193
|
end
|
176
194
|
end
|
@@ -180,7 +198,10 @@ describe Oddb2xml::BMUpdateDownloader do
|
|
180
198
|
before(:each) do
|
181
199
|
setup_bm_update_server_mock
|
182
200
|
@downloader = Oddb2xml::BMUpdateDownloader.new
|
201
|
+
common_before
|
183
202
|
end
|
203
|
+
after(:each) do common_after end
|
204
|
+
|
184
205
|
it_behaves_like 'any downloader'
|
185
206
|
context 'when download is called' do
|
186
207
|
let(:txt) { @downloader.download }
|
@@ -190,7 +211,7 @@ describe Oddb2xml::BMUpdateDownloader do
|
|
190
211
|
end
|
191
212
|
it 'should clean up current directory' do
|
192
213
|
expect { txt }.not_to raise_error
|
193
|
-
File.exist?('oddb2xml_files_bm_update.txt').should
|
214
|
+
# File.exist?('oddb2xml_files_bm_update.txt').should eq(false)
|
194
215
|
end
|
195
216
|
end
|
196
217
|
end
|
@@ -200,7 +221,10 @@ describe Oddb2xml::LppvDownloader do
|
|
200
221
|
before(:each) do
|
201
222
|
setup_lppv_server_mock
|
202
223
|
@downloader = Oddb2xml::LppvDownloader.new
|
224
|
+
common_before
|
203
225
|
end
|
226
|
+
after(:each) do common_after end
|
227
|
+
|
204
228
|
it_behaves_like 'any downloader'
|
205
229
|
context 'when download is called' do
|
206
230
|
let(:txt) { @downloader.download }
|
@@ -210,7 +234,7 @@ describe Oddb2xml::LppvDownloader do
|
|
210
234
|
end
|
211
235
|
it 'should clean up current directory' do
|
212
236
|
expect { txt }.not_to raise_error
|
213
|
-
File.exist?('oddb2xml_files_lppv.txt').should
|
237
|
+
# File.exist?('oddb2xml_files_lppv.txt').should eq(false)
|
214
238
|
end
|
215
239
|
end
|
216
240
|
end
|
@@ -220,7 +244,10 @@ describe Oddb2xml::MigelDownloader do
|
|
220
244
|
before(:each) do
|
221
245
|
setup_migel_server_mock
|
222
246
|
@downloader = Oddb2xml::MigelDownloader.new
|
247
|
+
common_before
|
223
248
|
end
|
249
|
+
after(:each) do common_after end
|
250
|
+
|
224
251
|
it_behaves_like 'any downloader'
|
225
252
|
context 'when download is called' do
|
226
253
|
let(:bin) { @downloader.download }
|
@@ -230,13 +257,18 @@ describe Oddb2xml::MigelDownloader do
|
|
230
257
|
end
|
231
258
|
it 'should clean up current directory' do
|
232
259
|
expect { bin }.not_to raise_error
|
233
|
-
File.exist?('oddb2xml_files_nonpharma.txt').should
|
260
|
+
File.exist?('oddb2xml_files_nonpharma.txt').should eq(false)
|
234
261
|
end
|
235
262
|
end
|
236
263
|
end
|
237
264
|
|
238
265
|
describe Oddb2xml::MedregbmDownloader do
|
239
266
|
include ServerMockHelper
|
267
|
+
before(:each) do
|
268
|
+
common_before
|
269
|
+
end
|
270
|
+
after(:each) do common_after end
|
271
|
+
|
240
272
|
context 'betrieb' do
|
241
273
|
before(:each) do
|
242
274
|
setup_medregbm_server_mock
|
@@ -251,7 +283,7 @@ describe Oddb2xml::MedregbmDownloader do
|
|
251
283
|
end
|
252
284
|
it 'should clean up current directory' do
|
253
285
|
expect { txt }.not_to raise_error
|
254
|
-
File.exist?('oddb_company.xls').should
|
286
|
+
File.exist?('oddb_company.xls').should eq(false)
|
255
287
|
end
|
256
288
|
end
|
257
289
|
end
|
@@ -268,7 +300,7 @@ describe Oddb2xml::MedregbmDownloader do
|
|
268
300
|
end
|
269
301
|
it 'should clean up current directory' do
|
270
302
|
expect { txt }.not_to raise_error
|
271
|
-
File.exist?('oddb_person.xls').should
|
303
|
+
File.exist?('oddb_person.xls').should eq(false)
|
272
304
|
end
|
273
305
|
end
|
274
306
|
end
|
@@ -279,7 +311,10 @@ describe Oddb2xml::ZurroseDownloader do
|
|
279
311
|
before(:each) do
|
280
312
|
setup_zurrose_server_mock
|
281
313
|
@downloader = Oddb2xml::ZurroseDownloader.new
|
314
|
+
common_before
|
282
315
|
end
|
316
|
+
after(:each) do common_after end
|
317
|
+
|
283
318
|
it_behaves_like 'any downloader'
|
284
319
|
context 'when download is called' do
|
285
320
|
let(:dat) { @downloader.download }
|
@@ -289,7 +324,7 @@ describe Oddb2xml::ZurroseDownloader do
|
|
289
324
|
end
|
290
325
|
it 'should clean up current directory' do
|
291
326
|
expect { dat }.not_to raise_error
|
292
|
-
File.exist?('oddb2xml_zurrose_transfer.dat').should
|
327
|
+
File.exist?('oddb2xml_zurrose_transfer.dat').should eq(false)
|
293
328
|
end
|
294
329
|
end
|
295
330
|
end
|
data/spec/extractor_spec.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
describe Oddb2xml::BagXmlExtractor do
|
15
15
|
context 'should handle articles with and without pharmacode' do
|
16
16
|
subject do
|
17
|
-
dat = File.read(File.
|
17
|
+
dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
|
18
18
|
Oddb2xml::BagXmlExtractor.new(dat).to_hash
|
19
19
|
end
|
20
20
|
it {
|
@@ -63,9 +63,9 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
63
63
|
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
|
64
64
|
it { expect(subject.to_hash).to be_empty }
|
65
65
|
end
|
66
|
-
context 'can parse
|
66
|
+
context 'can parse swissmedic_package.xlsx' do
|
67
67
|
it {
|
68
|
-
filename = File.join(
|
68
|
+
filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
|
69
69
|
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :package).to_hash
|
70
70
|
expect(@packs.size).to eq(14)
|
71
71
|
serocytol = nil
|
@@ -79,9 +79,9 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
79
79
|
expect(serocytol[:substance_swissmedic]).to eq('globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)')
|
80
80
|
}
|
81
81
|
end
|
82
|
-
context 'can parse
|
82
|
+
context 'can parse swissmedic_fridge.xlsx' do
|
83
83
|
it {
|
84
|
-
filename = File.join(
|
84
|
+
filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
|
85
85
|
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :fridge).to_arry
|
86
86
|
expect(@packs.size).to eq(17)
|
87
87
|
expect(@packs[0]).to eq("58618")
|
@@ -90,10 +90,10 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
90
90
|
end
|
91
91
|
context 'can parse swissmedic_orphans.xls' do
|
92
92
|
it {
|
93
|
-
filename = File.join(
|
93
|
+
filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
|
94
94
|
expect(File.exists?(filename)).to eq(true), "File #{filename} must exists"
|
95
95
|
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :orphan).to_arry
|
96
|
-
expect(@packs.size).to eq(
|
96
|
+
expect(@packs.size).to eq(78)
|
97
97
|
expect(@packs.first).to eq("62132")
|
98
98
|
expect(@packs[7]).to eq("00687")
|
99
99
|
}
|
@@ -103,7 +103,7 @@ end
|
|
103
103
|
describe Oddb2xml::EphaExtractor do
|
104
104
|
context 'can parse epha_interactions.csv' do
|
105
105
|
it {
|
106
|
-
filename = File.join(
|
106
|
+
filename = File.join(Oddb2xml::SpecData, 'epha_interactions.csv')
|
107
107
|
string = IO.read(filename)
|
108
108
|
@actions = Oddb2xml::EphaExtractor.new(string).to_arry
|
109
109
|
expect(@actions.size).to eq(2)
|
@@ -124,14 +124,14 @@ describe Oddb2xml::ZurroseExtractor do
|
|
124
124
|
subject { Oddb2xml::ZurroseExtractor.new(nil) }
|
125
125
|
it { expect(subject.to_hash).to be_empty }
|
126
126
|
end
|
127
|
-
context '
|
127
|
+
context 'it should work also when \n is the line ending' do
|
128
128
|
subject do
|
129
129
|
dat = <<-DAT
|
130
130
|
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
131
131
|
DAT
|
132
132
|
Oddb2xml::ZurroseExtractor.new(dat)
|
133
133
|
end
|
134
|
-
it {
|
134
|
+
it { subject.to_hash.size.should eq(1) }
|
135
135
|
end
|
136
136
|
context 'when expected line is given' do
|
137
137
|
subject do
|
@@ -142,7 +142,6 @@ describe Oddb2xml::ZurroseExtractor do
|
|
142
142
|
end
|
143
143
|
it { expect(subject.to_hash.keys.length).to eq(1) }
|
144
144
|
it { expect(subject.to_hash.keys.first).to eq("7680316440115") }
|
145
|
-
it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
|
146
145
|
it { expect(subject.to_hash.values.first[:price]).to eq("8.95") }
|
147
146
|
end
|
148
147
|
context 'when Estradiol Creme is given' do
|