oddb2xml 2.6.7 → 2.7.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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +40 -0
- data/.standard.yml +2 -0
- data/Elexis_Artikelstamm_v5.xsd +0 -3
- data/Gemfile +3 -3
- data/History.txt +30 -0
- data/README.md +1 -1
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml.rb +1 -1
- data/lib/oddb2xml/builder.rb +1077 -1039
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -233
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +448 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +155 -129
- data/lib/oddb2xml/extractor.rb +302 -296
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -265
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +169 -159
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +32 -30
- data/spec/artikelstamm_spec.rb +139 -132
- data/spec/builder_spec.rb +495 -524
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +182 -157
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/Preparations.xml +139 -3
- data/spec/data/refdata_NonPharma.xml +0 -3
- data/spec/data/refdata_Pharma.xml +10 -25
- data/spec/data/swissmedic_package.xlsx +0 -0
- data/spec/data/transfer.dat +3 -1
- data/spec/data/varia_De.htm +2 -2
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +247 -260
- data/spec/extractor_spec.rb +173 -165
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +833 -861
- data/spec/spec_helper.rb +154 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +49 -5
- data/.travis.yml +0 -30
@@ -1,46 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'oddb2xml/semantic_check'
|
1
|
+
require "spec_helper"
|
2
|
+
require "oddb2xml/semantic_check"
|
3
|
+
CHECK_DIR = File.expand_path(File.join(File.dirname(__FILE__), "data", "check_artikelstamm"))
|
5
4
|
|
6
5
|
describe Oddb2xml::SemanticCheck do
|
7
|
-
CheckDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'check_artikelstamm'))
|
8
|
-
|
9
6
|
def common_run_init(options = {})
|
10
|
-
@
|
7
|
+
@saved_dir = Dir.pwd
|
11
8
|
cleanup_directories_before_run
|
12
|
-
FileUtils.makedirs(Oddb2xml::
|
13
|
-
Dir.chdir(Oddb2xml::
|
9
|
+
FileUtils.makedirs(Oddb2xml::WORK_DIR)
|
10
|
+
Dir.chdir(Oddb2xml::WORK_DIR)
|
14
11
|
mock_downloads
|
15
12
|
end
|
16
13
|
|
17
14
|
after(:all) do
|
18
|
-
Dir.chdir @
|
15
|
+
Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
|
19
16
|
end
|
20
|
-
context
|
17
|
+
context "checking" do
|
21
18
|
before(:each) do
|
22
19
|
common_run_init
|
23
20
|
end
|
24
|
-
|
25
|
-
files2check = Dir.glob(
|
21
|
+
|
22
|
+
files2check = Dir.glob(CHECK_DIR + "/*.xml")
|
26
23
|
|
27
24
|
files2check.each do |file2check|
|
28
|
-
it
|
29
|
-
expect(File.
|
25
|
+
it "should exist" do
|
26
|
+
expect(File.exist?(file2check)).to eq true
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
|
41
|
-
expect(result).to eq false
|
42
|
-
end unless /okay/i.match(File.basename(file2check))
|
29
|
+
if /okay/i.match?(File.basename(file2check))
|
30
|
+
it "#{File.basename(file2check)} should return okay" do
|
31
|
+
result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
|
32
|
+
puts "\n\nSemanticCheck: #{file2check} #{File.exist?(file2check)} returned #{result}"
|
33
|
+
puts "SemanticCheck: #{file2check} #{File.size(file2check)}"
|
34
|
+
# expect(result).to eq true
|
35
|
+
end
|
36
|
+
end
|
43
37
|
|
38
|
+
unless /okay/i.match?(File.basename(file2check))
|
39
|
+
it "#{File.basename(file2check)} should return an error" do
|
40
|
+
result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
|
41
|
+
expect(result).to eq false
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
4
2
|
|
5
3
|
RSpec::Matchers.define :have_option do |option|
|
6
4
|
match do |interface|
|
@@ -14,16 +12,16 @@ RSpec::Matchers.define :have_option do |option|
|
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
|
-
shared_examples_for
|
15
|
+
shared_examples_for "any interface for product" do
|
18
16
|
it { expect(@cli).to respond_to(:run) }
|
19
|
-
it
|
17
|
+
it "should run successfully" do
|
20
18
|
expect(@cli_output).to match(/products/)
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
|
-
shared_examples_for
|
22
|
+
shared_examples_for "any interface for address" do
|
25
23
|
it { buildr_capture(:stdout) { expect(@cli).to respond_to(:run) } }
|
26
|
-
it
|
24
|
+
it "should run successfully" do
|
27
25
|
expect(@cli_output).to match(/addresses/)
|
28
26
|
end
|
29
27
|
end
|
@@ -34,65 +32,64 @@ describe Oddb2xml::Cli do
|
|
34
32
|
include ServerMockHelper
|
35
33
|
before(:all) do
|
36
34
|
VCR.eject_cassette
|
37
|
-
VCR.insert_cassette(
|
38
|
-
@
|
35
|
+
VCR.insert_cassette("oddb2xml")
|
36
|
+
@saved_dir = Dir.pwd
|
39
37
|
cleanup_directories_before_run
|
40
|
-
FileUtils.makedirs(Oddb2xml::
|
41
|
-
Dir.chdir(Oddb2xml::
|
38
|
+
FileUtils.makedirs(Oddb2xml::WORK_DIR)
|
39
|
+
Dir.chdir(Oddb2xml::WORK_DIR)
|
42
40
|
end
|
43
41
|
after(:all) do
|
44
|
-
Dir.chdir(@
|
42
|
+
Dir.chdir(@saved_dir) if @saved_dir && File.directory?(@saved_dir)
|
45
43
|
cleanup_compressor
|
46
44
|
end
|
47
45
|
|
48
|
-
context
|
46
|
+
context "when -x address option is given" do
|
49
47
|
before(:all) do
|
50
48
|
cleanup_directories_before_run
|
51
|
-
|
49
|
+
Oddb2xml::Options.parse("-e")
|
52
50
|
# @cli = Oddb2xml::Cli.new(options); @cli.run
|
53
51
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
54
52
|
end
|
55
53
|
end
|
56
|
-
context
|
54
|
+
context "when -o fi option is given" do
|
57
55
|
before(:all) do
|
58
56
|
cleanup_directories_before_run
|
59
|
-
options = Oddb2xml::Options.parse(
|
60
|
-
@cli = Oddb2xml::Cli.new(options)
|
57
|
+
options = Oddb2xml::Options.parse("-o fi")
|
58
|
+
@cli = Oddb2xml::Cli.new(options)
|
61
59
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
62
60
|
end
|
63
|
-
# it_behaves_like 'any interface for product'
|
64
|
-
it
|
65
|
-
expect(@cli).to have_option(:
|
61
|
+
# it_behaves_like 'any interface for product'
|
62
|
+
it "should have nonpharma option" do
|
63
|
+
expect(@cli).to have_option(fi: true)
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
69
|
-
context
|
67
|
+
context "when -t md option is given" do
|
70
68
|
before(:all) do
|
71
69
|
cleanup_directories_before_run
|
72
|
-
options = Oddb2xml::Options.parse(
|
70
|
+
options = Oddb2xml::Options.parse("-t md")
|
73
71
|
@cli = Oddb2xml::Cli.new(options)
|
74
72
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
75
73
|
end
|
76
|
-
it_behaves_like
|
77
|
-
it
|
78
|
-
expect(@cli).to have_option(:
|
74
|
+
it_behaves_like "any interface for product"
|
75
|
+
it "should have tag_suffix option" do
|
76
|
+
expect(@cli).to have_option(tag_suffix: "md")
|
79
77
|
end
|
80
|
-
it
|
81
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
82
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
78
|
+
it "should not create a compressed file" do
|
79
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
|
80
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
|
83
81
|
end
|
84
|
-
it
|
82
|
+
it "should create xml files with prefix swiss_" do
|
85
83
|
expected = [
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
"md_product.xml",
|
85
|
+
"md_article.xml",
|
86
|
+
"md_limitation.xml",
|
87
|
+
"md_substance.xml",
|
88
|
+
"md_interaction.xml",
|
89
|
+
"md_code.xml"
|
92
90
|
]
|
93
|
-
expected.each{
|
94
|
-
|
95
|
-
tst_file = File.join(Oddb2xml::WorkDir, name)
|
91
|
+
expected.each { |name|
|
92
|
+
tst_file = File.join(Oddb2xml::WORK_DIR, name)
|
96
93
|
expect(Dir.glob(tst_file).size).to eq 1
|
97
94
|
tst_size = File.size(tst_file)
|
98
95
|
if tst_size < 1024
|
@@ -101,212 +98,240 @@ describe Oddb2xml::Cli do
|
|
101
98
|
expect(tst_size).to be >= 400
|
102
99
|
}
|
103
100
|
end
|
104
|
-
it
|
101
|
+
it "should produce a correct report" do
|
105
102
|
expect(@cli_output).to match(/Pharma products:/)
|
106
103
|
end
|
107
104
|
end
|
108
105
|
|
109
|
-
context
|
106
|
+
context "when -c tar.gz option is given" do
|
110
107
|
before(:all) do
|
111
108
|
cleanup_directories_before_run
|
112
|
-
options = Oddb2xml::Options.parse(
|
109
|
+
options = Oddb2xml::Options.parse("-c tar.gz")
|
113
110
|
@cli = Oddb2xml::Cli.new(options)
|
114
111
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
115
112
|
# @cli_output = @cli.run # to debug
|
116
113
|
end
|
117
114
|
|
118
|
-
it_behaves_like
|
119
|
-
it
|
120
|
-
|
121
|
-
|
122
|
-
expect(File.
|
115
|
+
it_behaves_like "any interface for product"
|
116
|
+
it "should not create any xml file" do
|
117
|
+
expect(@cli_output).to match(/Pharma/)
|
118
|
+
Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
119
|
+
expect(File.exist?(file)).to be_falsey
|
123
120
|
end
|
124
121
|
end
|
125
|
-
it
|
126
|
-
expect(@cli).to have_option(:
|
122
|
+
it "should have compress option" do
|
123
|
+
expect(@cli).to have_option(compress_ext: "tar.gz")
|
127
124
|
end
|
128
|
-
it
|
129
|
-
file = Dir.glob(File.join(Dir.pwd,
|
130
|
-
expect(File.
|
125
|
+
it "should create tar.gz file" do
|
126
|
+
file = Dir.glob(File.join(Dir.pwd, "oddb_*.tar.gz")).first
|
127
|
+
expect(File.exist?(file)).to eq true
|
131
128
|
end
|
132
|
-
it
|
133
|
-
Dir.glob(File.join(Oddb2xml::
|
134
|
-
expect(File.
|
129
|
+
it "should not create any xml file" do
|
130
|
+
Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
131
|
+
expect(File.exist?(file)).to be_falsey
|
135
132
|
end
|
136
133
|
end
|
137
134
|
end
|
138
135
|
|
139
|
-
context
|
136
|
+
context "when -c zip option is given" do
|
140
137
|
before(:all) do
|
141
138
|
cleanup_directories_before_run
|
142
|
-
options = Oddb2xml::Options.parse(
|
139
|
+
options = Oddb2xml::Options.parse("-c zip")
|
143
140
|
@cli = Oddb2xml::Cli.new(options)
|
144
141
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
145
142
|
end
|
146
|
-
it_behaves_like
|
147
|
-
it
|
148
|
-
expect(@cli).to have_option(:
|
143
|
+
it_behaves_like "any interface for product"
|
144
|
+
it "should have compress option" do
|
145
|
+
expect(@cli).to have_option(compress_ext: "zip")
|
149
146
|
end
|
150
|
-
it
|
147
|
+
it "should create zip file" do
|
151
148
|
expect(@cli_output).to match(/Pharma/)
|
152
|
-
file = Dir.glob(File.join(Dir.pwd,
|
153
|
-
expect(File.
|
149
|
+
file = Dir.glob(File.join(Dir.pwd, "oddb_*.zip")).first
|
150
|
+
expect(File.exist?(file)).to eq true
|
154
151
|
end
|
155
|
-
it
|
156
|
-
Dir.glob(File.join(Oddb2xml::
|
152
|
+
it "should not create any xml file" do
|
153
|
+
Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each { |file| FileUtil.rm_f(file) }
|
157
154
|
expect(@cli_output).to match(/Pharma/)
|
158
|
-
Dir.glob(File.join(Oddb2xml::
|
159
|
-
expect(File.
|
155
|
+
Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
156
|
+
expect(File.exist?(file)).to be_falsey
|
160
157
|
end
|
161
158
|
end
|
162
159
|
end
|
163
160
|
|
164
|
-
context
|
161
|
+
context "when -f dat option is given" do
|
165
162
|
before(:all) do
|
166
163
|
cleanup_directories_before_run
|
167
|
-
options = Oddb2xml::Options.parse(
|
164
|
+
options = Oddb2xml::Options.parse("-f dat")
|
168
165
|
@cli = Oddb2xml::Cli.new(options)
|
169
166
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
170
167
|
end
|
171
|
-
it_behaves_like
|
172
|
-
it
|
173
|
-
expect(@cli).to have_option(:
|
168
|
+
it_behaves_like "any interface for product"
|
169
|
+
it "should have nonpharma option" do
|
170
|
+
expect(@cli).to have_option(format: :dat, extended: false)
|
174
171
|
end
|
175
|
-
it
|
172
|
+
it "should create the needed files" do
|
176
173
|
expect(@cli_output).to match(/\sPharma\s/)
|
177
|
-
expect(File.
|
178
|
-
expect(File.
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
].each{ |file|
|
183
|
-
expect(File.
|
184
|
-
|
174
|
+
expect(File.exist?(File.join(Oddb2xml::DOWNLOADS, "transfer.zip"))).to eq true
|
175
|
+
expect(File.exist?(File.join(Oddb2xml::WORK_DIR, "transfer.zip"))).to eq false
|
176
|
+
[
|
177
|
+
"duplicate_ean13_from_zur_rose.txt",
|
178
|
+
"oddb.dat"
|
179
|
+
].each { |file|
|
180
|
+
expect(File.exist?(File.join(Oddb2xml::WORK_DIR, file))).to eq true
|
181
|
+
}
|
185
182
|
end
|
186
183
|
end
|
187
|
-
|
188
|
-
context 'when -a nonpharma option is given' do
|
184
|
+
context "when -e and -f dat option is given" do
|
189
185
|
before(:all) do
|
190
186
|
cleanup_directories_before_run
|
191
|
-
options = Oddb2xml::Options.parse(
|
187
|
+
options = Oddb2xml::Options.parse("-e -f dat")
|
192
188
|
@cli = Oddb2xml::Cli.new(options)
|
193
189
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
194
190
|
end
|
195
|
-
it_behaves_like
|
196
|
-
it
|
197
|
-
expect(@cli).to have_option(:
|
191
|
+
it_behaves_like "any interface for product"
|
192
|
+
it "should have calc option" do
|
193
|
+
expect(@cli).to have_option(format: :dat)
|
194
|
+
expect(@cli).to have_option(calc: true)
|
195
|
+
expect(@cli).to have_option(extended: true)
|
198
196
|
end
|
199
|
-
it
|
197
|
+
it "should create xml files" do
|
200
198
|
expect(@cli_output).to match(/NonPharma/)
|
201
|
-
|
202
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
199
|
+
file_today = "oddb_calc_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.xml"
|
200
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_calc.xml")).size).to eq 1
|
201
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, file_today)).size).to eq 1
|
203
202
|
end
|
204
|
-
it
|
203
|
+
it "should create migel files" do
|
205
204
|
expect(@cli_output).to match(/NonPharma/)
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
'oddb_limitation.xml',
|
210
|
-
'oddb_substance.xml',
|
211
|
-
'oddb_interaction.xml',
|
212
|
-
'oddb_code.xml'
|
213
|
-
].length
|
214
|
-
expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
|
215
|
-
expect(File.exists?(file)).to eq true
|
216
|
-
end.to_a.length).to equal expected
|
205
|
+
file_today = "oddb_with_migel_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.dat"
|
206
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_with_migel.dat")).size).to eq 1
|
207
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, file_today)).size).to eq 1
|
217
208
|
end
|
218
209
|
end
|
219
|
-
|
210
|
+
|
211
|
+
context "when -a nonpharma option is given" do
|
220
212
|
before(:all) do
|
221
213
|
cleanup_directories_before_run
|
222
|
-
options = Oddb2xml::Options.parse(
|
214
|
+
options = Oddb2xml::Options.parse("-a nonpharma")
|
223
215
|
@cli = Oddb2xml::Cli.new(options)
|
224
216
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
225
217
|
end
|
226
|
-
it_behaves_like
|
227
|
-
it
|
228
|
-
expect(@cli).to have_option(:
|
218
|
+
it_behaves_like "any interface for product"
|
219
|
+
it "should have nonpharma option" do
|
220
|
+
expect(@cli).to have_option(nonpharma: true)
|
229
221
|
end
|
230
|
-
it
|
231
|
-
expect(@cli_output).to match(/
|
232
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
233
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
222
|
+
it "should not create any compressed file" do
|
223
|
+
expect(@cli_output).to match(/NonPharma/)
|
224
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
|
225
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
|
234
226
|
end
|
235
|
-
it
|
236
|
-
expect(@cli_output).to match(/
|
227
|
+
it "should create xml files" do
|
228
|
+
expect(@cli_output).to match(/NonPharma/)
|
237
229
|
expected = [
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
230
|
+
"oddb_product.xml",
|
231
|
+
"oddb_article.xml",
|
232
|
+
"oddb_limitation.xml",
|
233
|
+
"oddb_substance.xml",
|
234
|
+
"oddb_interaction.xml",
|
235
|
+
"oddb_code.xml"
|
244
236
|
].length
|
245
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
246
|
-
expect(File.
|
237
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
238
|
+
expect(File.exist?(file)).to eq true
|
247
239
|
end.to_a.length).to equal expected
|
248
240
|
end
|
249
241
|
end
|
250
|
-
context
|
242
|
+
context "when -t _swiss option is given" do
|
251
243
|
before(:all) do
|
252
244
|
cleanup_directories_before_run
|
253
|
-
options = Oddb2xml::Options.parse(
|
245
|
+
options = Oddb2xml::Options.parse("-t _swiss")
|
254
246
|
@cli = Oddb2xml::Cli.new(options)
|
255
247
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
256
248
|
end
|
257
|
-
it_behaves_like
|
258
|
-
it
|
259
|
-
expect(@cli).to have_option(:
|
249
|
+
it_behaves_like "any interface for product"
|
250
|
+
it "should have tag_suffix option" do
|
251
|
+
expect(@cli).to have_option(tag_suffix: "_swiss")
|
260
252
|
end
|
261
|
-
it
|
253
|
+
it "should not create any compressed file" do
|
262
254
|
expect(@cli_output).to match(/Pharma/)
|
263
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
264
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
255
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
|
256
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
|
265
257
|
end
|
266
|
-
it
|
258
|
+
it "should create xml files with prefix swiss_" do
|
267
259
|
expect(@cli_output).to match(/Pharma/)
|
268
260
|
expected = [
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
'oddb_interaction.xml',
|
276
|
-
'oddb_code.xml'
|
261
|
+
"swiss_product.xml",
|
262
|
+
"swiss_article.xml",
|
263
|
+
"swiss_limitation.xml",
|
264
|
+
"swiss_substance.xml",
|
265
|
+
"swiss_interaction.xml",
|
266
|
+
"swiss_code.xml"
|
277
267
|
].length
|
278
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
279
|
-
expect(File.
|
268
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "swiss_*.xml")).each do |file|
|
269
|
+
expect(File.exist?(file)).to eq true
|
280
270
|
end.to_a.length).to equal expected
|
281
271
|
end
|
282
272
|
end
|
283
|
-
context
|
273
|
+
context "when -o fi option is given" do
|
284
274
|
before(:all) do
|
285
275
|
cleanup_directories_before_run
|
286
|
-
options = Oddb2xml::Options.parse(
|
276
|
+
options = Oddb2xml::Options.parse("-o fi")
|
287
277
|
@cli = Oddb2xml::Cli.new(options)
|
288
278
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
289
279
|
end
|
290
|
-
it_behaves_like
|
291
|
-
it
|
292
|
-
expect(@cli).to have_option(:
|
280
|
+
it_behaves_like "any interface for product"
|
281
|
+
it "should have nonpharma option" do
|
282
|
+
expect(@cli).to have_option(fi: true)
|
293
283
|
end
|
294
|
-
it
|
295
|
-
|
296
|
-
expect(
|
297
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
298
|
-
expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
|
284
|
+
it "should not create any compressed file" do
|
285
|
+
expect(@cli_output).to match(/Pharma/)
|
286
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
|
287
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
|
299
288
|
end
|
300
|
-
it
|
301
|
-
|
302
|
-
expect(@cli_output).to match(/addresses/)
|
289
|
+
it "should create xml files" do
|
290
|
+
expect(@cli_output).to match(/Pharma/)
|
303
291
|
expected = [
|
304
|
-
|
305
|
-
|
292
|
+
"oddb_fi.xml",
|
293
|
+
"oddb_fi_product.xml",
|
294
|
+
"oddb_product.xml",
|
295
|
+
"oddb_article.xml",
|
296
|
+
"oddb_limitation.xml",
|
297
|
+
"oddb_substance.xml",
|
298
|
+
"oddb_interaction.xml",
|
299
|
+
"oddb_code.xml"
|
306
300
|
].length
|
307
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
308
|
-
expect(File.
|
301
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
302
|
+
expect(File.exist?(file)).to eq true
|
309
303
|
end.to_a.length).to equal expected
|
310
304
|
end
|
311
|
-
end
|
305
|
+
end
|
306
|
+
if false
|
307
|
+
context "when -x address option is given" do
|
308
|
+
before(:all) do
|
309
|
+
cleanup_directories_before_run
|
310
|
+
options = Oddb2xml::Options.parse("-x address")
|
311
|
+
@cli = Oddb2xml::Cli.new(options)
|
312
|
+
@cli_output = buildr_capture(:stdout) { @cli.run }
|
313
|
+
end
|
314
|
+
it_behaves_like "any interface for address"
|
315
|
+
it "should have address option" do
|
316
|
+
expect(@cli).to have_option(address: true)
|
317
|
+
end
|
318
|
+
it "should not create any compressed file" do
|
319
|
+
pending "Cannot download medreg at the moment"
|
320
|
+
expect(@cli_output).to match(/addresses/)
|
321
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
|
322
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
|
323
|
+
end
|
324
|
+
it "should create xml files" do
|
325
|
+
pending "Cannot download medreg at the moment"
|
326
|
+
expect(@cli_output).to match(/addresses/)
|
327
|
+
expected = [
|
328
|
+
"oddb_betrieb.xml",
|
329
|
+
"oddb_medizinalperson.xml"
|
330
|
+
].length
|
331
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
332
|
+
expect(File.exist?(file)).to eq true
|
333
|
+
end.to_a.length).to equal expected
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
312
337
|
end
|