oddb2xml 2.6.9 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- 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 +28 -0
- data/README.md +3 -3
- 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 +1075 -1048
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -235
- 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 +156 -128
- data/lib/oddb2xml/extractor.rb +295 -302
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +166 -164
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +32 -31
- data/spec/artikelstamm_spec.rb +116 -135
- 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 +173 -174
- 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/refdata_NonPharma.xml +0 -3
- data/spec/data/refdata_Pharma.xml +0 -26
- data/spec/data/transfer.dat +1 -0
- data/spec/data/varia_De.htm +2 -2
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +251 -260
- data/spec/extractor_spec.rb +172 -164
- 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 +153 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +48 -5
- data/.travis.yml +0 -29
@@ -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,238 +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
|
-
context
|
184
|
+
context "when -e and -f dat option is given" do
|
188
185
|
before(:all) do
|
189
186
|
cleanup_directories_before_run
|
190
|
-
options = Oddb2xml::Options.parse(
|
187
|
+
options = Oddb2xml::Options.parse("-e -f dat")
|
191
188
|
@cli = Oddb2xml::Cli.new(options)
|
192
189
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
193
190
|
end
|
194
|
-
it_behaves_like
|
195
|
-
it
|
196
|
-
expect(@cli).to have_option(:
|
197
|
-
expect(@cli).to have_option(:
|
198
|
-
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)
|
199
196
|
end
|
200
|
-
it
|
197
|
+
it "should create xml files" do
|
201
198
|
expect(@cli_output).to match(/NonPharma/)
|
202
199
|
file_today = "oddb_calc_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.xml"
|
203
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
204
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
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
|
205
202
|
end
|
206
|
-
it
|
203
|
+
it "should create migel files" do
|
207
204
|
expect(@cli_output).to match(/NonPharma/)
|
208
205
|
file_today = "oddb_with_migel_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.dat"
|
209
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
210
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
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
|
211
208
|
end
|
212
209
|
end
|
213
210
|
|
214
|
-
context
|
211
|
+
context "when -a nonpharma option is given" do
|
215
212
|
before(:all) do
|
216
213
|
cleanup_directories_before_run
|
217
|
-
options = Oddb2xml::Options.parse(
|
214
|
+
options = Oddb2xml::Options.parse("-a nonpharma")
|
218
215
|
@cli = Oddb2xml::Cli.new(options)
|
219
216
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
220
217
|
end
|
221
|
-
it_behaves_like
|
222
|
-
it
|
223
|
-
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)
|
224
221
|
end
|
225
|
-
it
|
222
|
+
it "should not create any compressed file" do
|
226
223
|
expect(@cli_output).to match(/NonPharma/)
|
227
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
228
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
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
|
229
226
|
end
|
230
|
-
it
|
227
|
+
it "should create xml files" do
|
231
228
|
expect(@cli_output).to match(/NonPharma/)
|
232
229
|
expected = [
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
230
|
+
"oddb_product.xml",
|
231
|
+
"oddb_article.xml",
|
232
|
+
"oddb_limitation.xml",
|
233
|
+
"oddb_substance.xml",
|
234
|
+
"oddb_interaction.xml",
|
235
|
+
"oddb_code.xml"
|
239
236
|
].length
|
240
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
241
|
-
expect(File.
|
237
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
238
|
+
expect(File.exist?(file)).to eq true
|
242
239
|
end.to_a.length).to equal expected
|
243
240
|
end
|
244
241
|
end
|
245
|
-
context
|
242
|
+
context "when -t _swiss option is given" do
|
246
243
|
before(:all) do
|
247
244
|
cleanup_directories_before_run
|
248
|
-
options = Oddb2xml::Options.parse(
|
245
|
+
options = Oddb2xml::Options.parse("-t _swiss")
|
249
246
|
@cli = Oddb2xml::Cli.new(options)
|
250
247
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
251
248
|
end
|
252
|
-
it_behaves_like
|
253
|
-
it
|
254
|
-
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")
|
255
252
|
end
|
256
|
-
it
|
253
|
+
it "should not create any compressed file" do
|
257
254
|
expect(@cli_output).to match(/Pharma/)
|
258
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
259
|
-
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
|
260
257
|
end
|
261
|
-
it
|
258
|
+
it "should create xml files with prefix swiss_" do
|
262
259
|
expect(@cli_output).to match(/Pharma/)
|
263
260
|
expected = [
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
261
|
+
"swiss_product.xml",
|
262
|
+
"swiss_article.xml",
|
263
|
+
"swiss_limitation.xml",
|
264
|
+
"swiss_substance.xml",
|
265
|
+
"swiss_interaction.xml",
|
266
|
+
"swiss_code.xml"
|
270
267
|
].length
|
271
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
272
|
-
expect(File.
|
268
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "swiss_*.xml")).each do |file|
|
269
|
+
expect(File.exist?(file)).to eq true
|
273
270
|
end.to_a.length).to equal expected
|
274
271
|
end
|
275
272
|
end
|
276
|
-
context
|
273
|
+
context "when -o fi option is given" do
|
277
274
|
before(:all) do
|
278
275
|
cleanup_directories_before_run
|
279
|
-
options = Oddb2xml::Options.parse(
|
276
|
+
options = Oddb2xml::Options.parse("-o fi")
|
280
277
|
@cli = Oddb2xml::Cli.new(options)
|
281
278
|
@cli_output = buildr_capture(:stdout) { @cli.run }
|
282
279
|
end
|
283
|
-
it_behaves_like
|
284
|
-
it
|
285
|
-
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)
|
286
283
|
end
|
287
|
-
it
|
284
|
+
it "should not create any compressed file" do
|
288
285
|
expect(@cli_output).to match(/Pharma/)
|
289
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
290
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
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
|
291
288
|
end
|
292
|
-
it
|
289
|
+
it "should create xml files" do
|
293
290
|
expect(@cli_output).to match(/Pharma/)
|
294
291
|
expected = [
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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"
|
303
300
|
].length
|
304
|
-
expect(Dir.glob(File.join(Oddb2xml::
|
305
|
-
expect(File.
|
301
|
+
expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
|
302
|
+
expect(File.exist?(file)).to eq true
|
306
303
|
end.to_a.length).to equal expected
|
307
304
|
end
|
308
305
|
end
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
expect(File.
|
335
|
-
|
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
|
336
335
|
end
|
337
|
-
end
|
336
|
+
end
|
338
337
|
end
|