sandozxmlconv 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env ruby
2
+ # Conversion::TestWbmbBdd -- xmlconv2 -- 23.08.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/wbmb_bdd'
9
+ require 'soap/marshal'
10
+ require 'mock'
11
+ require 'flexmock'
12
+
13
+ module XmlConv
14
+ module Conversion
15
+ class TestWbmbBdd < Test::Unit::TestCase
16
+ def setup
17
+ @src = <<-XML
18
+ <?xml version="1.0" encoding="ISO-8859-1" ?>
19
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
20
+ <SOAP-ENV:Body>
21
+ <wbmb:auftrag xmlns:wbmb="http://ywesee.com/wbmb" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
22
+ <wbmb:absender xsi:type="enc:Array" enc:arrayType="wbmb:identifier[3]">
23
+ <wbmb:identifier>
24
+ <wbmb:idtype>name</wbmb:idtype>
25
+ <wbmb:idvalue>ywesee Testspit�ler</wbmb:idvalue>
26
+ </wbmb:identifier>
27
+ <wbmb:identifier>
28
+ <wbmb:idtype>kundennummer</wbmb:idtype>
29
+ <wbmb:idvalue>99</wbmb:idvalue>
30
+ </wbmb:identifier>
31
+ <wbmb:identifier>
32
+ <wbmb:idtype>auftragsnummer</wbmb:idtype>
33
+ <wbmb:idvalue>10019</wbmb:idvalue>
34
+ </wbmb:identifier>
35
+ </wbmb:absender>
36
+ <wbmb:empfaenger xsi:type="enc:Array" enc:arrayType="wbmb:identifier[2]">
37
+ <wbmb:identifier>
38
+ <wbmb:idtype>ean13</wbmb:idtype>
39
+ <wbmb:idvalue>7601001000681</wbmb:idvalue>
40
+ </wbmb:identifier>
41
+ <wbmb:identifier>
42
+ <wbmb:idtype>auftragsnummer</wbmb:idtype>
43
+ <wbmb:idvalue>76</wbmb:idvalue>
44
+ </wbmb:identifier>
45
+ </wbmb:empfaenger>
46
+ <wbmb:artikelliste xsi:type="enc:Array" enc:arrayType="wbmb:artikel[1]">
47
+ <wbmb:artikel>
48
+ <wbmb:position>1</wbmb:position>
49
+ <wbmb:identifier>
50
+ <wbmb:idtype>gag-code</wbmb:idtype>
51
+ <wbmb:idvalue>300976</wbmb:idvalue>
52
+ </wbmb:identifier>
53
+ <wbmb:identifier>
54
+ <wbmb:idtype>ean13</wbmb:idtype>
55
+ <wbmb:idvalue>1234567890123</wbmb:idvalue>
56
+ </wbmb:identifier>
57
+ <wbmb:identifier>
58
+ <wbmb:idtype>pharmacode</wbmb:idtype>
59
+ <wbmb:idvalue>1234567</wbmb:idvalue>
60
+ </wbmb:identifier>
61
+ <wbmb:bestellmenge>12</wbmb:bestellmenge>
62
+ <wbmb:artikelpreis>6.20</wbmb:artikelpreis>
63
+ </wbmb:artikel>
64
+ </wbmb:artikelliste>
65
+ <wbmb:auftrag_info xsi:type="enc:Array" enc:arrayType="wbmb:info[5]">
66
+ <wbmb:info>
67
+ <wbmb:infotype>text</wbmb:infotype>
68
+ <wbmb:infovalue>Diese Bestellung ist dringend!</wbmb:infovalue>
69
+ </wbmb:info>
70
+ <wbmb:info>
71
+ <wbmb:infotype>lieferung_bis</wbmb:infotype>
72
+ <wbmb:infovalue>2003-03-01 08:30:00</wbmb:infovalue>
73
+ </wbmb:info>
74
+ <wbmb:info>
75
+ <wbmb:infotype>lieferadresse</wbmb:infotype>
76
+ <wbmb:address xsi:type="enc:Array" enc:arrayType="wbmb:info[7]">
77
+ <wbmb:info>
78
+ <wbmb:infotype>name</wbmb:infotype>
79
+ <wbmb:infovalue>ywesee</wbmb:infovalue>
80
+ </wbmb:info>
81
+ <wbmb:info>
82
+ <wbmb:infotype>name</wbmb:infotype>
83
+ <wbmb:infovalue>intellectual capital connected</wbmb:infovalue>
84
+ </wbmb:info>
85
+ <wbmb:info>
86
+ <wbmb:infotype>strasse</wbmb:infotype>
87
+ <wbmb:infovalue>Postfach 1234</wbmb:infovalue>
88
+ </wbmb:info>
89
+ <wbmb:info>
90
+ <wbmb:infotype>strasse</wbmb:infotype>
91
+ <wbmb:infovalue>Winterthurerstrasse 52</wbmb:infovalue>
92
+ </wbmb:info>
93
+ <wbmb:info>
94
+ <wbmb:infotype>plz</wbmb:infotype>
95
+ <wbmb:infovalue>8006</wbmb:infovalue>
96
+ </wbmb:info>
97
+ <wbmb:info>
98
+ <wbmb:infotype>ort</wbmb:infotype>
99
+ <wbmb:infovalue>Zuerich</wbmb:infovalue>
100
+ </wbmb:info>
101
+ <wbmb:info>
102
+ <wbmb:infotype>land</wbmb:infotype>
103
+ <wbmb:infovalue>Schweiz</wbmb:infovalue>
104
+ </wbmb:info>
105
+ </wbmb:address>
106
+ </wbmb:info>
107
+ <wbmb:info>
108
+ <wbmb:infotype>versandkosten</wbmb:infotype>
109
+ <wbmb:infovalue>12.34</wbmb:infovalue>
110
+ </wbmb:info>
111
+ <wbmb:info>
112
+ <wbmb:infotype>schnittstelle</wbmb:infotype>
113
+ <wbmb:infovalue>62</wbmb:infovalue>
114
+ </wbmb:info>
115
+ </wbmb:auftrag_info>
116
+ </wbmb:auftrag>
117
+ </SOAP-ENV:Body>
118
+ </SOAP-ENV:Envelope>
119
+ XML
120
+ end
121
+ def test_convert
122
+ bdd = WbmbBdd.convert(WbmbBdd.parse(@src))
123
+ assert_instance_of(Model::Bdd, bdd)
124
+ assert_equal(1, bdd.deliveries.size)
125
+ delivery = bdd.deliveries.first
126
+ customer = delivery.customer
127
+ assert_instance_of(Model::Party, customer)
128
+ assert_equal('ywesee Testspit�ler', customer.name.to_s)
129
+ assert_equal('99', customer.acc_id)
130
+ assert_equal('10019', delivery.customer_id)
131
+ seller = delivery.seller
132
+ assert_equal('76', delivery.acc_id)
133
+ assert_equal('7601001000681', seller.acc_id)
134
+ assert_equal(1, delivery.items.size)
135
+ assert_equal("Diese Bestellung ist dringend!", delivery.free_text)
136
+ end
137
+ def test_parse
138
+ auftrag = WbmbBdd.parse(@src)
139
+ assert_respond_to(auftrag, :absender)
140
+ absender = auftrag.absender
141
+ assert_instance_of(Array, absender)
142
+ assert_equal(3, absender.size)
143
+ id = absender.first
144
+ assert_equal('name', id.idtype)
145
+ assert_equal(Iconv.iconv('utf8', 'latin1', 'ywesee Testspit�ler').first,
146
+ id.idvalue)
147
+ end
148
+ def test_convert__robust
149
+ src = <<-XML
150
+ <?xml version="1.0" encoding="ISO-8859-1" ?>
151
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
152
+ <SOAP-ENV:Body>
153
+ <wbmb:auftrag xmlns:wbmb="http://ywesee.com/wbmb" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
154
+ <wbmb:absender xsi:type="enc:Array" enc:arrayType="wbmb:identifier[3]">
155
+ <wbmb:identifier>
156
+ <wbmb:idtype>name</wbmb:idtype>
157
+ <wbmb:idvalue>ywesee Testspit�ler</wbmb:idvalue>
158
+ </wbmb:identifier>
159
+ <wbmb:identifier>
160
+ <wbmb:idtype>kundennummer</wbmb:idtype>
161
+ <wbmb:idvalue>99</wbmb:idvalue>
162
+ </wbmb:identifier>
163
+ <wbmb:identifier>
164
+ <wbmb:idtype>auftragsnummer</wbmb:idtype>
165
+ <wbmb:idvalue>10019</wbmb:idvalue>
166
+ </wbmb:identifier>
167
+ </wbmb:absender>
168
+ <wbmb:empfaenger xsi:type="enc:Array" enc:arrayType="wbmb:identifier[2]">
169
+ <wbmb:identifier>
170
+ <wbmb:idtype>ean13</wbmb:idtype>
171
+ <wbmb:idvalue>7601001000681</wbmb:idvalue>
172
+ </wbmb:identifier>
173
+ <wbmb:identifier>
174
+ <wbmb:idtype>auftragsnummer</wbmb:idtype>
175
+ <wbmb:idvalue>76</wbmb:idvalue>
176
+ </wbmb:identifier>
177
+ </wbmb:empfaenger>
178
+ <wbmb:artikelliste xsi:type="enc:Array" enc:arrayType="wbmb:artikel[1]">
179
+ <wbmb:artikel>
180
+ <wbmb:position>1</wbmb:position>
181
+ <wbmb:identifier>
182
+ <wbmb:idtype>gag-code</wbmb:idtype>
183
+ <wbmb:idvalue>300976</wbmb:idvalue>
184
+ </wbmb:identifier>
185
+ <wbmb:identifier>
186
+ <wbmb:idtype>ean13</wbmb:idtype>
187
+ <wbmb:idvalue>1234567890123</wbmb:idvalue>
188
+ </wbmb:identifier>
189
+ <wbmb:identifier>
190
+ <wbmb:idtype>pharmacode</wbmb:idtype>
191
+ <wbmb:idvalue>1234567</wbmb:idvalue>
192
+ </wbmb:identifier>
193
+ <wbmb:bestellmenge>12</wbmb:bestellmenge>
194
+ </wbmb:artikel>
195
+ </wbmb:artikelliste>
196
+ </wbmb:auftrag>
197
+ </SOAP-ENV:Body>
198
+ </SOAP-ENV:Envelope>
199
+ XML
200
+ assert_nothing_raised {
201
+ WbmbBdd.convert(WbmbBdd.parse(src))
202
+ }
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+ # TestPharmaciePlusBdd -- xmlconv2 -- 18.08.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/xundart_bdd'
9
+
10
+ module XmlConv
11
+ module Conversion
12
+ class TestGehBdd < Test::Unit::TestCase
13
+ def setup
14
+ @src = <<-XML
15
+ <?xml version="1.0" encoding="iso-8859-1"?>
16
+ <commande xmlns="http://www.xundart.ch" date="7/2/2009 5:29:52 PM" id="1234">
17
+ <com-pharma ean="7601010273543">
18
+ <livraison><last-name>Dr. med. Xxxxx Xxxxxx</last-name><address><street>Xxxxxxxxxxxxxxxxx 19</street><zip>9524</zip><city>Zuzwil</city></address></livraison>
19
+ <article ean="7680568730217" pharmacode="3938385" qte_facture="19"><desc>Torasemid Sandoz eco Tabl 2.5 mg 20 Stk</desc></article>
20
+ <article ean="7680569080175" pharmacode="3729807" qte_facture="2"><desc>Omeprazol Sandoz eco Filmtabl/Stechamp Filmtabl 20 mg 56 Stk</desc></article>
21
+ <article ean="7680162790136" pharmacode="0384673" qte_facture="3"><desc>Calcium Sandoz Ampullen 90 mg 10% 5x10 ml Ampullen</desc></article></com-pharma>
22
+
23
+ <com-pharma ean="7601010273963">
24
+ <livraison><last-name>Dr. med. Xxxxxxxxx Xxxxxxx</last-name><address><street>Xxxxxxxxxxxxx 3</street><zip>9602</zip><city>Bazenheid</city></address></livraison>
25
+ <article ean="7680560350208" pharmacode="3275944" qte_facture="3"><desc>Simcora Filmtabl 60 mg 100 Stk</desc></article></com-pharma>
26
+
27
+ <com-pharma ean="7601000000000">
28
+ <livraison><last-name> Max Muster</last-name><address><street>St. Jakob-Strasse 56a</street><zip>9000</zip><city>St. Gallen</city></address></livraison>
29
+ <article ean="7680562030047" pharmacode="3296509" qte_facture="5"><desc>Amoxicillin Sandoz Disp Tabl 1000 mg 20 Tabl</desc></article>
30
+ <article ean="7680162790136" pharmacode="0384673" qte_facture="1"><desc>Calcium Sandoz Ampullen 90 mg 10% 5x10 ml Ampullen</desc></article>
31
+ <article ean="7680562030184" pharmacode="3401484" qte_facture="10"><desc>Amoxicillin Sandoz Disp Tabl 750 mg 20 Tabl</desc></article></com-pharma>
32
+ </commande>
33
+ XML
34
+ @xml_doc = REXML::Document.new(@src)
35
+ end
36
+ def test_parse
37
+ document = XundartBdd.parse(@src)
38
+ assert_instance_of(REXML::Document, document)
39
+ end
40
+ def test_convert
41
+ bdd = XundartBdd.convert(@xml_doc)
42
+ assert_instance_of(Model::Bdd, bdd)
43
+ assert_equal(3, bdd.deliveries.size)
44
+ delivery = bdd.deliveries.first
45
+ assert_instance_of(Model::Delivery, delivery)
46
+ assert_equal('1234', delivery.customer_id)
47
+ bsr = delivery.bsr
48
+ assert_instance_of(Model::Bsr, bsr)
49
+ assert_equal('7601010273543', delivery.bsr_id)
50
+ customer = delivery.customer
51
+ assert_instance_of(Model::Party, customer)
52
+ shipto = customer.ship_to
53
+ assert_instance_of(Model::Party, shipto)
54
+ name = shipto.name
55
+ assert_instance_of(Model::Name, name)
56
+ expected = "Dr. med. Xxxxx Xxxxxx"
57
+ assert_equal(expected, name.to_s)
58
+ address = shipto.address
59
+ assert_instance_of(Model::Address, address)
60
+ assert_equal(["Xxxxxxxxxxxxxxxxx 19"],
61
+ address.lines)
62
+ assert_equal("9524", address.zip_code)
63
+ assert_equal("Zuzwil", address.city)
64
+ assert_equal(3, delivery.items.size)
65
+
66
+ assert_equal 3, delivery.items.size
67
+ item = delivery.items.first
68
+ assert_instance_of(Model::DeliveryItem, item)
69
+ assert_equal('1', item.line_no)
70
+ assert_equal('7680568730217', item.et_nummer_id)
71
+ assert_equal('3938385', item.pharmacode_id)
72
+ assert_equal('19', item.qty)
73
+
74
+ #bsr = delivery.bsr
75
+ #assert_instance_of(Model::Bsr, bsr)
76
+
77
+ ## last delivery:
78
+ delivery = bdd.deliveries.last
79
+ assert_instance_of(Model::Delivery, delivery)
80
+ assert_equal('1234', delivery.customer_id)
81
+ assert_equal('7601000000000', delivery.bsr_id)
82
+ customer = delivery.customer
83
+ assert_instance_of(Model::Party, customer)
84
+ name = customer.name
85
+ assert_instance_of(Model::Name, name)
86
+ expected = "Max Muster"
87
+ assert_equal(expected, name.to_s)
88
+ expected = "St. Jakob-Strasse 56a"
89
+ assert_equal(expected, customer.ship_to.address.lines.first)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env ruby
2
+ # TestPharmaciePlusI2 -- xmlconv2 -- 21.08.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'xmlconv/util/transaction'
9
+ require 'xmlconv/util/destination'
10
+ require 'conversion/pharmacieplus_bdd'
11
+ require 'conversion/bdd_csv'
12
+
13
+ module XmlConv
14
+ module Integration
15
+ class TestXmlI2 < Test::Unit::TestCase
16
+ def setup
17
+ @src = <<-XML
18
+ <?xml version="1.0" encoding="ISO-8859-1"?>
19
+ <commande id="1861" date="2006-08-16T09:32:35.303+02:00" xmlns="http://www.ofac.ch/XEDO">
20
+ <groupe>
21
+ <last-name>pharmacieplus Directe</last-name>
22
+ <first-name> </first-name>
23
+ <other-name>Messieurs Eric Bussat + Christian Rouvinez</other-name>
24
+ <address>
25
+ <street>les courbes 5</street>
26
+ <zip>1121</zip>
27
+ <city>Bremblens</city>
28
+ </address>
29
+ <telecom>
30
+ <phone number="021 811 48 88"/>
31
+ <fax number="021 811 48 89"/>
32
+ </telecom>
33
+ <online>
34
+ <email>secretariat@pharmacieplus.ch</email>
35
+ </online>
36
+ </groupe>
37
+ <fournisseur ean="7601001000681">
38
+ <last-name>GLOBOPHARM AG</last-name>
39
+ <first-name> </first-name>
40
+ <address>
41
+ <street>Seestrasse 200</street>
42
+ <zip>8700</zip>
43
+ <city>KUESNACHT</city>
44
+ <country>CH</country>
45
+ </address>
46
+ </fournisseur>
47
+ <com-global>
48
+ <article ean="7680543802083" pharmacode="2054106" qte-livraison="12" qte-facture="10">
49
+ <desc>ANTRA MUPS 10 Tabl 10 mg 100 Stk</desc>
50
+ <cond-com>
51
+ <bonus facture="10" livre="12"/>
52
+ </cond-com>
53
+ </article>
54
+ <article ean="7680543800386" pharmacode="2054081" qte-livraison="12" qte-facture="10">
55
+ <desc>ANTRA MUPS 10 Tabl 10 mg 28 Stk</desc>
56
+ <cond-com>
57
+ <bonus facture="10" livre="12"/>
58
+ </cond-com>
59
+ </article>
60
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="30" qte-facture="20">
61
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
62
+ <cond-com>
63
+ <bonus facture="10" livre="15"/>
64
+ </cond-com>
65
+ </article>
66
+ <article ean="7680543802403" pharmacode="2054158" qte-livraison="15" qte-facture="10">
67
+ <desc>ANTRA MUPS 20 Tabl 20 mg 100 Stk</desc>
68
+ <cond-com>
69
+ <bonus facture="10" livre="15"/>
70
+ </cond-com>
71
+ </article>
72
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="13" qte-facture="13">
73
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
74
+ <cond-com rabais="10.0"/>
75
+ </article>
76
+ <article ean="7680543800973" pharmacode="2054135" qte-livraison="28" qte-facture="20">
77
+ <desc>ANTRA MUPS 20 Tabl 20 mg 28 Stk</desc>
78
+ <cond-com>
79
+ <bonus facture="10" livre="14"/>
80
+ </cond-com>
81
+ </article>
82
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="17" qte-facture="17">
83
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
84
+ <cond-com rabais="15.0"/>
85
+ </article>
86
+ <article ean="7680543800706" pharmacode="2054112" qte-livraison="28" qte-facture="20">
87
+ <desc>ANTRA MUPS 20 Tabl 20 mg 7 Stk</desc>
88
+ <cond-com>
89
+ <bonus facture="10" livre="14"/>
90
+ </cond-com>
91
+ </article>
92
+ <article ean="7680548750532" pharmacode="2204899" qte-livraison="11" qte-facture="11">
93
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 28 Stk</desc>
94
+ <cond-com rabais="5.0"/>
95
+ </article>
96
+ <article ean="7680548750617" pharmacode="2204907" qte-livraison="30" qte-facture="20">
97
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 98 Stk</desc>
98
+ <cond-com>
99
+ <bonus facture="10" livre="15"/>
100
+ </cond-com>
101
+ </article>
102
+ </com-global>
103
+ <com-pharma ean="7601001368095">
104
+ <livraison>
105
+ <last-name>Pharmacie du Mandement</last-name>
106
+ <first-name> </first-name>
107
+ <other-name> Madame Fran�oise Recipient </other-name>
108
+ <address>
109
+ <street>3e adresse e-mail</street>
110
+ <zip>1242</zip>
111
+ <city>Satigny</city>
112
+ </address>
113
+ </livraison>
114
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="15" qte-facture="10">
115
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
116
+ </article>
117
+ <article ean="7680543802403" pharmacode="2054158" qte-livraison="15" qte-facture="10">
118
+ <desc>ANTRA MUPS 20 Tabl 20 mg 100 Stk</desc>
119
+ </article>
120
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="6" qte-facture="6">
121
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
122
+ </article>
123
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="9" qte-facture="9">
124
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
125
+ </article>
126
+ <article ean="7680543800706" pharmacode="2054112" qte-livraison="28" qte-facture="20">
127
+ <desc>ANTRA MUPS 20 Tabl 20 mg 7 Stk</desc>
128
+ </article>
129
+ <article ean="7680548750532" pharmacode="2204899" qte-livraison="11" qte-facture="11">
130
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 28 Stk</desc>
131
+ </article>
132
+ <article ean="7680548750617" pharmacode="2204907" qte-livraison="30" qte-facture="20">
133
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 98 Stk</desc>
134
+ </article>
135
+ </com-pharma>
136
+ <com-pharma ean="7601001368491">
137
+ <livraison>
138
+ <last-name>Pharm. Ecole-de-M�decine</last-name>
139
+ <first-name> </first-name>
140
+ <other-name> </other-name>
141
+ <address>
142
+ <street>3e adresse e-mail</street>
143
+ <zip>1205</zip>
144
+ <city>Gen�ve</city>
145
+ </address>
146
+ </livraison>
147
+ <article ean="7680543802083" pharmacode="2054106" qte-livraison="12" qte-facture="10">
148
+ <desc>ANTRA MUPS 10 Tabl 10 mg 100 Stk</desc>
149
+ </article>
150
+ <article ean="7680543800386" pharmacode="2054081" qte-livraison="12" qte-facture="10">
151
+ <desc>ANTRA MUPS 10 Tabl 10 mg 28 Stk</desc>
152
+ </article>
153
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="15" qte-facture="10">
154
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
155
+ </article>
156
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="7" qte-facture="7">
157
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
158
+ </article>
159
+ <article ean="7680543800973" pharmacode="2054135" qte-livraison="28" qte-facture="20">
160
+ <desc>ANTRA MUPS 20 Tabl 20 mg 28 Stk</desc>
161
+ </article>
162
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="8" qte-facture="8">
163
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
164
+ </article>
165
+ </com-pharma>
166
+ </commande>
167
+ XML
168
+ @xml_doc = REXML::Document.new(@src)
169
+ @target_dir = File.expand_path('data/pharmacieplus_csv',
170
+ File.dirname(__FILE__))
171
+ clear_dir
172
+ end
173
+ def teardown
174
+ clear_dir
175
+ end
176
+ def clear_dir
177
+ if(File.exist?(@target_dir))
178
+ FileUtils.rm_r(@target_dir)
179
+ end
180
+ end
181
+ def test_pharmacieplus_csv
182
+ XmlConv::CONFIG.default_filename = "%s%s_%s.txt"
183
+ bdd = Conversion::PharmaciePlusBdd.convert(@xml_doc)
184
+ csv_docs = Conversion::BddCsv.convert(bdd)
185
+ assert_instance_of(Array, csv_docs)
186
+ csv_doc = csv_docs.first
187
+ assert_match(/^7601001368095_.*\.txt/, csv_doc.filename)
188
+ result = csv_doc.to_s.split("\n")
189
+ dstr = Date.today.strftime("%d%m%Y")
190
+ expected = <<-EOS
191
+ ,7601001368095,#{dstr},,2054098,7680543801949,,10,,1861,
192
+ ,7601001368095,#{dstr},,2054158,7680543802403,,10,,1861,
193
+ ,7601001368095,#{dstr},,2054129,7680543800898,,6,,1861,
194
+ ,7601001368095,#{dstr},,2054141,7680543802328,,9,,1861,
195
+ ,7601001368095,#{dstr},,2054112,7680543800706,,20,,1861,
196
+ ,7601001368095,#{dstr},,2204899,7680548750532,,11,,1861,
197
+ ,7601001368095,#{dstr},,2204907,7680548750617,,20,,1861,
198
+ EOS
199
+ expected.split("\n").each_with_index { |line, index|
200
+ assert_equal(line, result[index])
201
+ }
202
+ end
203
+ end
204
+ end
205
+ end