sandoz.bbmb.ch 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +26 -0
  4. data/Gemfile +12 -0
  5. data/History.txt +6 -0
  6. data/LICENSE +339 -0
  7. data/Rakefile +21 -0
  8. data/doc/index.rbx +14 -0
  9. data/doc/resources/activex/BbmbBarcodeReader.CAB +0 -0
  10. data/doc/resources/activex/BbmbBarcodeReader2.CAB +0 -0
  11. data/doc/resources/bbmb.css +301 -0
  12. data/doc/resources/errors/appdown.html +14 -0
  13. data/doc/resources/javascript/bcreader.js +131 -0
  14. data/doc/resources/javascript/order.js +65 -0
  15. data/doc/resources/javascript/widget/ContentToggler.js +60 -0
  16. data/doc/resources/javascript/widget/__package__.js +2 -0
  17. data/doc/resources/javascript/widget/templates/ContentToggler.html +4 -0
  18. data/doc/resources/logo.png +0 -0
  19. data/lib/bbmb/html/util/lookandfeel.rb +202 -0
  20. data/lib/bbmb/sandoz.rb +4 -0
  21. data/lib/bbmb/sandoz/html/state/viral/customer.rb +25 -0
  22. data/lib/bbmb/sandoz/version.rb +5 -0
  23. data/lib/bbmb/util/csv_importer.rb +123 -0
  24. data/readme.md +28 -0
  25. data/sandoz.bbmb.ch.gemspec +45 -0
  26. data/test/rcov +2 -0
  27. data/test/selenium.rb +1687 -0
  28. data/test/selenium/selenium-server.jar +0 -0
  29. data/test/selenium/test_current_order.rb +336 -0
  30. data/test/selenium/test_customer.rb +363 -0
  31. data/test/selenium/test_customers.rb +92 -0
  32. data/test/selenium/test_favorites.rb +257 -0
  33. data/test/selenium/test_favorites_result.rb +81 -0
  34. data/test/selenium/test_history.rb +112 -0
  35. data/test/selenium/test_login.rb +112 -0
  36. data/test/selenium/test_orders.rb +111 -0
  37. data/test/selenium/test_result.rb +157 -0
  38. data/test/selenium/unit.rb +146 -0
  39. data/test/stub/http_server.rb +140 -0
  40. data/test/stub/persistence.rb +58 -0
  41. data/test/suite.rb +15 -0
  42. data/test/util/data/Artikel.TXT +50 -0
  43. data/test/util/data/Kunden.TXT +14 -0
  44. data/test/util/test_csv_importer.rb +136 -0
  45. metadata +414 -0
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+ # Stub.http_server -- bbmb.ch -- 21.09.2006 -- hwyss@ywesee.com
3
+
4
+ require 'sbsm/request'
5
+ require 'sbsm/trans_handler'
6
+ require 'stub/persistence'
7
+ require 'webrick'
8
+
9
+ ## compatibility-brainfuck for integrating Apache-SBSM-Requests with WEBrick
10
+
11
+ module BBMB
12
+ module Stub
13
+ class Notes < Hash
14
+ alias :add :store
15
+ end
16
+ class Output < String
17
+ alias :write :<<
18
+ alias :print :<<
19
+ end
20
+ class HTTPServer < WEBrick::HTTPServer
21
+ attr_accessor :document_root, :inject_params
22
+ def method_missing(method, *args, &block)
23
+ @logger.warn "ignoring method: #{method}"
24
+ end
25
+ end
26
+ def Stub.http_server(drburi, log_level=0)
27
+ doc = File.expand_path('../../doc', File.dirname(__FILE__))
28
+ logger = WEBrick::Log.new
29
+ logger.level = log_level
30
+ config = { :Host => 'localhost', :Port => 10080,
31
+ :DocumentRoot => doc, :Logger => logger }
32
+ if(log_level == 0)
33
+ config.store(:AccessLog, [])
34
+ end
35
+ server = HTTPServer.new(config)
36
+ server.document_root = doc
37
+ bbmb = Proc.new { |req, resp|
38
+ if(req.uri == '/favicon.ico')
39
+ resp.body = File.open(File.join(doc, req.uri))
40
+ else
41
+ ARGV.push('')
42
+ req.server = server
43
+ req.uri = CGI.unescape(req.uri)
44
+ SBSM::TransHandler.instance.translate_uri(req)
45
+ ## not Threadsafe!
46
+ SBSM::Apache.request = req
47
+ output = Output.new
48
+ sbsm = SBSM::Request.new(drburi)
49
+ sbsm.meta_eval { define_method(:handle_exception) { |e| raise e } }
50
+ sbsm.cgi.params.update(req.query)
51
+ if prms = server.inject_params
52
+ sbsm.cgi.params.update(prms)
53
+ server.inject_params = nil
54
+ end
55
+ sbsm.cgi.env_table['SERVER_NAME'] =
56
+ BBMB.config.http_server.gsub('http://', '') + ':10080'
57
+ sbsm.cgi.env_table['REQUEST_METHOD'] = req.request_method
58
+ req.cookies.each { |cookie|
59
+ sbsm.cgi.cookies[cookie.name] = cookie.value
60
+ }
61
+ # override _session_id
62
+ sbsm.cgi.cookies['_session_id'] = 'test:preset-session-id'
63
+ sbsm.cgi.output = output
64
+ sbsm.process
65
+ if(/^location:/i.match(output))
66
+ resp.status = 303
67
+ end
68
+ resp.rawdata = true
69
+ resp.body = output
70
+ end
71
+ }
72
+ server.mount_proc('/', &bbmb)
73
+ server.mount_proc('/de', &bbmb)
74
+ server.mount_proc('/de/.*', &bbmb)
75
+ res = File.join(doc, 'resources')
76
+ server.mount('/resources', WEBrick::HTTPServlet::FileHandler, res, {})
77
+ server
78
+ end
79
+ end
80
+ end
81
+ module WEBrick
82
+ class HTTPRequest
83
+ attr_accessor :server, :uri, :notes
84
+ alias :__old_initialize__ :initialize
85
+ def initialize(*args)
86
+ __old_initialize__(*args)
87
+ @notes = BBMB::Stub::Notes.new
88
+ end
89
+ def headers_in
90
+ headers = {}
91
+ if(@header)
92
+ @header.each { |key, vals| headers.store(key, vals.join(';')) }
93
+ end
94
+ headers
95
+ end
96
+ def uri
97
+ @uri || unparsed_uri
98
+ end
99
+ end
100
+ class HTTPResponse
101
+ attr_accessor :rawdata
102
+ alias :__old_send_header__ :send_header
103
+ def send_header(socket)
104
+ if(@rawdata)
105
+ _write_data(socket, status_line)
106
+ else
107
+ __old_send_header__(socket)
108
+ end
109
+ end
110
+ alias :__old_setup_header__ :setup_header
111
+ def setup_header()
112
+ unless(@rawdata)
113
+ __old_setup_header__
114
+ end
115
+ end
116
+ end
117
+ end
118
+ module SBSM
119
+ class Request
120
+ def handle_exception(e)
121
+ raise e
122
+ end
123
+ end
124
+ module Apache
125
+ DECLINED = nil
126
+ def Apache.request=(request)
127
+ @request = request
128
+ end
129
+ def Apache.request
130
+ @request
131
+ end
132
+ end
133
+ end
134
+ class CGI
135
+ attr_accessor :output
136
+ def stdoutput
137
+ output
138
+ end
139
+ public :env_table
140
+ end
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ # Persistence::Test -- bbmb.ch -- 14.09.2006 -- hwyss@ywesee.com
3
+
4
+ require 'bbmb/model/customer'
5
+ require 'bbmb/model/product'
6
+ require 'bbmb/model/promotion'
7
+
8
+ class Object
9
+ def meta_class; class << self; self; end; end
10
+ def meta_eval &blk; meta_class.instance_eval &blk; end
11
+ end
12
+ module BBMB
13
+ module Persistable
14
+ def Persistable.append_features(mod)
15
+ super
16
+ mod.module_eval {
17
+ alias :__test_initialize__ :initialize
18
+ @instances = []
19
+ def initialize(*args)
20
+ __test_initialize__(*args)
21
+ self.class.instances.push(self)
22
+ end
23
+ class << self
24
+ attr_reader :instances
25
+ def clear_instances
26
+ @instances.clear
27
+ end
28
+ def index(*keys)
29
+ index_suffix = keys.join('_and_')
30
+ method_name = sprintf("find_by_%s", index_suffix)
31
+ meta_eval {
32
+ define_method(method_name) { |*vals|
33
+ @instances.find { |instance|
34
+ vals == keys.collect { |key| instance.send(key) }
35
+ }
36
+ }
37
+ }
38
+ end
39
+ end
40
+ }
41
+ end
42
+ end
43
+ module Model
44
+ class Product
45
+ include Persistable
46
+ index :article_number
47
+ index :ean13
48
+ index :description
49
+ index :pcode
50
+ end
51
+ class Customer
52
+ include Persistable
53
+ index :customer_id
54
+ index :email
55
+ index :ean13
56
+ end
57
+ end
58
+ end
data/test/suite.rb ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # suite.rb -- oddb -- 08.09.2006 -- hwyss@ywesee.com
3
+
4
+ here = File.expand_path(File.dirname(__FILE__))
5
+ $: << here
6
+
7
+ require 'find'
8
+
9
+ Find.find(here) do |file|
10
+ if /test_.*\.rb$/o.match(file)
11
+ next if /selenium/i.match(file)
12
+ require file
13
+ end
14
+ end
15
+
@@ -0,0 +1,50 @@
1
+ 00510680 RANIMED 300MG 60FCT CH RANIMED 300MG 60FCT CH 7680540570671 1959294 25.25
2
+ 00546829 BILOL 5 mg Filmtbl 30 BILOL 5MG 30FCT CH 7680540300100 2324008 8.29
3
+ 00559059 CIP eco 250 mg Filmtbl 20 CIP ECO 250MG 20FCT CH 7680555250148 2508381 20.00
4
+ 00570868 SIMCORA 20MG 100FCT CH SIMCORA 20MG 100FCT CH 7680560350048 2762470 70.35
5
+ 00578068 TORASIS 5MG 20TAB CH TORASIS 5MG 20TAB CH 7680568730101 2965724 4.20
6
+ 00579584 PRAVASTA ECO 40MG 30TAB CH PRAVASTA ECO 40MG 30TAB CH 7680564540131 2965664 17.34
7
+ 00589894 TERBIFIL 125MF 14 TABL. TERBIFIL 125MF 14 TABL. 0.00
8
+ 00598516 CARVEDILOL Sandoz 25 mg Tbl 100 CARVEDILOL SDZ 25MG 100TAB CH 7680576060092 39.50
9
+ 00601286 CAPTOSOL 25 mg Tbl 100 CAPTOSOL 25MG 100TAB CH 7680529860526 1922138 19.80
10
+ 00610552 OMEPRAZOL Sandoz Eco 40 mg Kps 28 OMEPRAZOL SDZ ECO 40MG 28GRC BO CH 7680572700213 3463427 52.48
11
+ 00611802 DOXORUBICIN Sandoz 100mg/50ml Amp 1 DOXORUBICIN SDZ 100MG/50ML 50ML 1LIVI CH 0.00
12
+ 00622007 FINASTERID Sandoz 5mg Tbl 30 FINASTERID SDZ 5MG 30FCT CH 0.00
13
+ 00965786 OSPEN 750 750000IU/5ML 120ML 1SSP CH OSPEN 750 750000IU/5ML 120ML 1SSP CH 7680370570612 0879943 22.49
14
+ 00990672 GABAPENTIN Sandoz 600mg Filmtbl 100 GABAPENTIN SDZ 600MG 100FCT CH 7680576160037 3515986 68.85
15
+ 44001617 ECOVENT 0.5% 100ML 1LIIN CH ECOVENT 0.5% 100ML 1LIIN CH 7680483170228 1363905 22.50
16
+ 44012102 VENLAFAXINE SDZ 37.5MG 100TAB CH VENLAFAXINE SDZ 37.5MG 100TAB CH 0.00
17
+ 44001100 SIMVASTATIN SDZ 20MG 28FCT CH SIMVASTATIN SDZ 20MG 28FCT CH 7680571770064 2837334 20.01
18
+ 44001101 SIMVASTATIN SDZ 20MG 98FCT CH SIMVASTATIN SDZ 20MG 98FCT CH 7680571770088 2837340 68.67
19
+ 44001102 SIMVASTATIN SDZ 40MG 28FCT CH SIMVASTATIN SDZ 40MG 28FCT CH 7680571770101 2837357 20.01
20
+ 44001103 SIMVASTATIN SDZ 40MG 98FCT CH SIMVASTATIN SDZ 40MG 98FCT CH 7680571770125 2837363 68.67
21
+ 44001104 CYPROTERONACETAT EE Sandoz Drag 21 CYPROTERONACETAT EE SDZ 21FCT CH 7680573320113 2951691 6.12
22
+ 44001105 CYPROTERONACETAT EE Sandoz Drag 3 x 21 CYPROTERONACETAT EE SDZ 63FCT CH 7680573320137 2951716 19.20
23
+ 44001106 DOXYCYCLIN Sandoz 100 mg Kps 8 DOXYCYCLIN SDZ 100MG 8SGC CH 7680452930686 2993353 4.04
24
+ 44001107 DICLOFENAC Sandoz Filmtabl 50 mg 20 Stk DICLOFENAC SDZ 50MG 20FCT CH 7680573760056 2993301 5.07
25
+ 44001108 DICLOFENAC Sandoz Filmtabl 50 mg 100 Stk DICLOFENAC SDZ 50MG 100FCT CH 7680573760070 2993324 19.98
26
+ 44001618 ECOVENT 0.2MG/DOS 200DOS PWDI CH ECOVENT 0.2MG/DOS 200DOS PWDI CH 7680531900227 1913524 14.99
27
+ 44001619 CROMOSOL 20MG/2ML 2ML 20LIIN CH CROMOSOL 20MG/2ML 2ML 20LIIN CH 7680531040107 1680706 7.58
28
+ 44001630 CROMOSOL 20MG/2ML 2ML 50LIIN CH CROMOSOL 20MG/2ML 2ML 50LIIN CH 7680531040299 1680712 18.19
29
+ 44001631 BECECO Easyhaler Plv 0.2 mg 200 Dosis BECECO 0.2MG/DOS 200DOS PWDI CH 7680539500276 2771339 34.67
30
+ 44001632 ACC eco 600 mg Brausetbl 7 ACC ECO 600MG 7EFT CH 7680539850258 1808193 4.52
31
+ 44001633 ACC eco 200 mg Brausetbl 20 ACC ECO 200MG 20EFT CH 7680539850173 1808187 4.31
32
+ 44001634 ACC eco 600 mg Gran Btl 10 ACC ECO 600MG 10POS CH 7680556220010 2315506 6.45
33
+ 44001635 TIMISOL 0.25% 0.4ML 30LDP CH TIMISOL 0.25% 0.4ML 30LDP CH 7680543700167 2092555 9.86
34
+ 44001636 TIMISOL 0.5% 0.4ML 30LDP CH TIMISOL 0.5% 0.4ML 30LDP CH 7680543700242 2092561 11.18
35
+ 44001637 CROMOSOL OPHTA 20MG/0.5ML 0.5ML 20LDP CH CROMOSOL OPHTA 20MG/0.5ML 0.5ML 20LDP CH 7680535340234 1960630 7.18
36
+ 44001638 CROMOSOL OPHTA 20MG/0.5ML 0.5ML 40LDP CH CROMOSOL OPHTA 20MG/0.5ML 0.5ML 40LDP CH 7680535340159 1837243 12.80
37
+ 44002724 ALFUZOSIN Sandoz 10 mg Ret. Tbl 10 ALFUZOSIN SDZ 10MG 10PRT CH 3162915 8.29
38
+ 44002725 ALFUZOSIN Sandoz 10 mg Ret. Tbl 30 ALFUZOSIN SDZ 10MG 30PRT CH 3162921 22.26
39
+ 44012103 VENLAFAXINE SDZ 75MG 30TAB CH VENLAFAXINE SDZ 75MG 30TAB CH 0.00
40
+ 44012104 VENLAFAXINE SDZ 75MG 100TAB CH VENLAFAXINE SDZ 75MG 100TAB CH 0.00
41
+ 00995148 RIMACTAN 150MG 16HGC CH RIMACTAN 150MG 16HGC CH 7680342790123 22.08
42
+ 00995149 RIMACTAN 300MG 8HGC CH RIMACTAN 300MG 8HGC CH 7680342790390 21.00
43
+ 00995150 RIMACTAN 300MG 40HGC CH RIMACTAN 300MG 40HGC CH 7680342790390 97.88
44
+ 00997276 METFORMIN Sandoz Filmtabl 850 mg 100 Stk METFORMIN SDZ 850MG 100FCT CH 7680564970068 2919492 10.99
45
+ 00997277 METFORMIN Sandoz Filmtabl 850 mg 30 Stk METFORMIN SDZ 850MG 30FCT CH 7680564970044 2919486 4.99
46
+ 00997409 CEFUROXIM Sandoz 250mg Filmtbl 14 CEFUROXIM SDZ 250MG 14TAB CH 15.03
47
+ 00997410 CEFUROXIM Sandoz 500mg Filmtbl 14 CEFUROXIM SDZ 500MG 14TAB CH 7680559870106 24.71
48
+ 00997652 FLUCONAZOL Sandoz 150 mg Kps 1 FLUCONAZOL SDZ 150MG 1HGC CH 7680570100053 2970062 7.50
49
+ 00997653 FLUCONAZOL Sandoz 150 mg Kps 4 FLUCONAZOL SDZ 150MG 4HGC CH 7680570100077 2970079 26.40
50
+ 00997654 FLUCONAZOL Sandoz 200 mg Kps 2 FLUCONAZOL SDZ 200MG 2HGC CH 7680570100091 2970085 14.95
@@ -0,0 +1,14 @@
1
+ 4100603650 7601001024410 Publikums-Apotheke Frau Nelly Schaller Park-Apotheke Hauptstrasse 78 8280 Kreuzlingen 071 672 40 55 071 672 40 50
2
+ 4100603418 7601001367319 Publikums-Apotheke Frau Silvia Hofmann Eulen-Apotheke AG Wallisellenstrasse 333 8050 Z�rich 044 322 34 15 044 322 24 46
3
+ 4100602684 7601001303744 Publikums-Apotheke Herr Dr. Walter Bertschi Park-Apotheke Gutstrasse 162 8055 Z�rich 044 492 70 80 044 491 06 60
4
+ 4100602592 7601001356801 Publikums-Apotheke Herr Dr. Eric Ziegler Nord-Apotheke AG Topwell-Apotheke AG Wehntalerstrasse 537 8046 Z�rich 044 371 06 05 044 371 67 34
5
+ 4100603347 7601001017818 Publikums-Apotheke Frau Damaris Bucher Gallus-Apotheke Oberer Graben 22 9000 St. Gallen 071 222 24 44 071 222 87 80
6
+ 4100602686 7601001007789 Publikums-Apotheke Frau Silvia Gerber Quintilius-Apotheke Grabenstrasse 8184 Bachenb�lach 044 860 29 19 044 860 32 13
7
+ 4100603260 7601001006812 Publikums-Apotheke Herr Dr. Beat Disler Rosen-Apotheke Allschwilerstr. /Rudolfstrasse 4 4054 Basel 061 302 53 53 061 302 16 16
8
+ 4100603248 7601001251595 Publikums-Apotheke Frau Eva Schiller Stern-Apotheke Laufenstrasse 62 4053 Basel 061 331 31 66 061 331 41 13
9
+ 4100602663 7601001022102 Publikums-Apotheke Herr Dr. Rudolf Andres Stadelhofen-Apotheke Goethestrasse 22 8001 Z�rich 044 268 30 00 044 268 30 04
10
+ 4100606346 7601001373549 Publikums-Apotheke Frau Carin Kranendonk Heuried-Apotheke Topwell-Apotheke AG Birmensdorferstrasse 379 8055 Z�rich 044 462 05 77 044 462 05 87
11
+ 4100602675 7601001370265 Publikums-Apotheke Herr Gerald Welbergen Apotheke im Br�hl AG Regensdorferstrasse 18 8049 Z�rich 044 342 42 12 044 342 42 17
12
+ 4100603089 7601001367869 Publikums-Apotheke Frau Elisabeth Simeth Fortuna Apotheke Tittwiesenstrasse 55 7000 Chur 081 284 20 22 081 284 50 25
13
+ 4100602666 7601001365803 Publikums-Apotheke Frau Christiane Kock-Hecht Odeon Apotheke AG Limmatquai 2 8001 Z�rich 044 252 59 59 044 252 59 62
14
+ 4100602680 7601001007062 Publikums-Apotheke Herr & Frau Dr. K. & C. Egloff Olympia-Apotheke Badenerstrasse 6 8004 Z�rich 044 241 36 88 044 241 36 43
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env ruby
2
+ # Util::TestCsvImporter -- sandoz.bbmb.ch -- 19.11.2007 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require "minitest/autorun"
8
+ require 'flexmock/test_unit'
9
+ require 'stub/persistence'
10
+ require 'bbmb/util/csv_importer'
11
+
12
+ module BBMB
13
+ module Util
14
+ class TestCsvImporter < Minitest::Test
15
+ include FlexMock::TestCase
16
+ def test_import
17
+ src = StringIO.new "\344\366\374"
18
+ importer = flexmock(CsvImporter.new)
19
+ importer.should_receive(:import_record).and_return { |record|
20
+ assert_equal(u("äöü"), record.first)
21
+ }
22
+ importer.import(src)
23
+ end
24
+ def test_string
25
+ importer = CsvImporter.new
26
+ assert_nil(importer.string(''))
27
+ end
28
+ end
29
+ class TestCustomerImporter < Minitest::Test
30
+ include FlexMock::TestCase
31
+ def setup
32
+ Model::Customer.clear_instances
33
+ BBMB.server = flexmock('server')
34
+ BBMB.server.should_ignore_missing
35
+ @dir = File.expand_path('data', File.dirname(__FILE__))
36
+ end
37
+ def test_import
38
+ src = File.open(File.join(@dir, 'Kunden.TXT'))
39
+ persistence = flexmock("persistence")
40
+ persistence.should_receive(:save).times(14).and_return { |customer|
41
+ assert_instance_of(Model::Customer, customer)
42
+ }
43
+ CustomerImporter.new.import(src, persistence)
44
+ end
45
+ def test_import_record
46
+ line = StringIO.new <<-EOS
47
+ 4100603650 7601001024410 Publikums-Apotheke Frau Nxxxx Sxxxxxxx Pxxx-Axxxxxxx Hxxxxxxxxxxx XX XXXX Kxxxxxxxxxx 0XX XXX XX 55 0XX XXX XX 50
48
+ EOS
49
+ importer = CustomerImporter.new
50
+ persistence = flexmock("persistence")
51
+ persistence.should_receive(:save).times(1)\
52
+ .and_return { |customer|
53
+ assert_instance_of(Model::Customer, customer)
54
+ assert_equal("4100603650", customer.customer_id)
55
+ assert_equal("7601001024410", customer.ean13)
56
+ assert_equal("Frau", customer.title)
57
+ assert_equal("Nxxxx", customer.firstname)
58
+ assert_equal("Sxxxxxxx", customer.lastname)
59
+ assert_equal("Pxxx-Axxxxxxx", customer.organisation)
60
+ assert_equal("Hxxxxxxxxxxx XX", customer.address1)
61
+ assert_equal("XXXX", customer.plz)
62
+ assert_equal("Kxxxxxxxxxx", customer.city)
63
+ assert_equal("0XX XXX XX 55", customer.phone_business)
64
+ assert_equal("0XX XXX XX 50", customer.fax)
65
+ }
66
+ importer.import(line, persistence)
67
+ end
68
+ def test_import_record__protected
69
+ line = StringIO.new <<-EOS
70
+ 4100603650 7601001024410 Publikums-Apotheke Frau Nxxxx Sxxxxxxx Pxxx-Axxxxxxx Hxxxxxxxxxxx XX XXXX Kxxxxxxxxxx 0XX XXX XX 55 0XX XXX XX 50
71
+ EOS
72
+ customer = Model::Customer.new("4100603650")
73
+ customer.address1 = 'corrected line'
74
+ customer.protect!(:address1)
75
+ importer = CustomerImporter.new
76
+ persistence = flexmock("persistence")
77
+ persistence.should_receive(:save).times(1)\
78
+ .and_return { |customer|
79
+ assert_instance_of(Model::Customer, customer)
80
+ assert_equal("4100603650", customer.customer_id)
81
+ assert_equal("7601001024410", customer.ean13)
82
+ assert_equal("Frau", customer.title)
83
+ assert_equal("Nxxxx", customer.firstname)
84
+ assert_equal("Sxxxxxxx", customer.lastname)
85
+ assert_equal("Pxxx-Axxxxxxx", customer.organisation)
86
+ assert_equal("corrected line", customer.address1)
87
+ assert_equal("XXXX", customer.plz)
88
+ assert_equal("Kxxxxxxxxxx", customer.city)
89
+ assert_equal("0XX XXX XX 55", customer.phone_business)
90
+ assert_equal("0XX XXX XX 50", customer.fax)
91
+ }
92
+ importer.import(line, persistence)
93
+ end
94
+ end
95
+ class TestProductImporter < Minitest::Test
96
+ include FlexMock::TestCase
97
+ def setup
98
+ Model::Product.clear_instances
99
+ @dir = File.expand_path('data', File.dirname(__FILE__))
100
+ end
101
+ def test_import
102
+ src = File.open(File.join(@dir, 'Artikel.TXT'))
103
+ persistence = flexmock("persistence")
104
+ persistence.should_receive(:save).times(50).with(Model::Product)
105
+ persistence.should_receive(:all)
106
+ ProductImporter.new.import(src, persistence)
107
+ end
108
+ def test_import_record
109
+ existing = Model::Product.new("00510680")
110
+ line = StringIO.new <<-EOS
111
+ 00546829 BILOL 5 mg Filmtbl 30 BILOL 5MG 30FCT CH 7680540300100 2324008 8.29
112
+ EOS
113
+ persistence = flexmock("persistence")
114
+ persistence.should_receive(:save).and_return { |product|
115
+ assert_instance_of(Model::Product, product)
116
+ assert_equal("00546829", product.article_number)
117
+ assert_equal("BILOL 5 mg Filmtbl 30", product.description.de)
118
+ assert_equal("BILOL 5MG 30FCT CH", product.description.fr)
119
+ assert_equal(8.29, product.price)
120
+ assert_equal("7680540300100", product.ean13)
121
+ assert_equal("2324008", product.pcode)
122
+ }
123
+ persistence.should_receive(:all).and_return { |klass, block|
124
+ case klass.name
125
+ when "BBMB::Model::Product"
126
+ block.call(existing)
127
+ when "BBMB::Model::Customer"
128
+ block.call(klass.new('test'))
129
+ end
130
+ }
131
+ persistence.should_receive(:delete).with(existing)
132
+ ProductImporter.new.import(line, persistence)
133
+ end
134
+ end
135
+ end
136
+ end
metadata ADDED
@@ -0,0 +1,414 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sandoz.bbmb.ch
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: odba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: ydbd-pg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: ydbi
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sbsm
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: htmlgrid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ydim
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.5.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.5.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: syck
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rmail
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rclconf
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: needle
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: hpricot
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: bbmb
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 2.0.1
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 2.0.1
195
+ - !ruby/object:Gem::Dependency
196
+ name: deprecated
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 2.0.1
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 2.0.1
209
+ - !ruby/object:Gem::Dependency
210
+ name: yus
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: bundler
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: simplecov
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rake
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: flexmock
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: test-unit
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: minitest
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: rspec
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
321
+ description: Sandoz skin for BBMB. A Ruby gem
322
+ email: mhatakeyama@ywesee.com, zdavatz@ywesee.com, ngiger@ywesee.com
323
+ executables: []
324
+ extensions: []
325
+ extra_rdoc_files: []
326
+ files:
327
+ - ".gitignore"
328
+ - ".travis.yml"
329
+ - Gemfile
330
+ - History.txt
331
+ - LICENSE
332
+ - Rakefile
333
+ - doc/index.rbx
334
+ - doc/resources/activex/BbmbBarcodeReader.CAB
335
+ - doc/resources/activex/BbmbBarcodeReader2.CAB
336
+ - doc/resources/bbmb.css
337
+ - doc/resources/errors/appdown.html
338
+ - doc/resources/javascript/bcreader.js
339
+ - doc/resources/javascript/order.js
340
+ - doc/resources/javascript/widget/ContentToggler.js
341
+ - doc/resources/javascript/widget/__package__.js
342
+ - doc/resources/javascript/widget/templates/ContentToggler.html
343
+ - doc/resources/logo.png
344
+ - lib/bbmb/html/util/lookandfeel.rb
345
+ - lib/bbmb/sandoz.rb
346
+ - lib/bbmb/sandoz/html/state/viral/customer.rb
347
+ - lib/bbmb/sandoz/version.rb
348
+ - lib/bbmb/util/csv_importer.rb
349
+ - readme.md
350
+ - sandoz.bbmb.ch.gemspec
351
+ - test/rcov
352
+ - test/selenium.rb
353
+ - test/selenium/selenium-server.jar
354
+ - test/selenium/test_current_order.rb
355
+ - test/selenium/test_customer.rb
356
+ - test/selenium/test_customers.rb
357
+ - test/selenium/test_favorites.rb
358
+ - test/selenium/test_favorites_result.rb
359
+ - test/selenium/test_history.rb
360
+ - test/selenium/test_login.rb
361
+ - test/selenium/test_orders.rb
362
+ - test/selenium/test_result.rb
363
+ - test/selenium/unit.rb
364
+ - test/stub/http_server.rb
365
+ - test/stub/persistence.rb
366
+ - test/suite.rb
367
+ - test/util/data/Artikel.TXT
368
+ - test/util/data/Kunden.TXT
369
+ - test/util/test_csv_importer.rb
370
+ homepage: https://github.com/zdavatz/sandoz.bbmb.ch
371
+ licenses:
372
+ - GPL-v2
373
+ metadata: {}
374
+ post_install_message:
375
+ rdoc_options: []
376
+ require_paths:
377
+ - lib
378
+ required_ruby_version: !ruby/object:Gem::Requirement
379
+ requirements:
380
+ - - ">="
381
+ - !ruby/object:Gem::Version
382
+ version: '0'
383
+ required_rubygems_version: !ruby/object:Gem::Requirement
384
+ requirements:
385
+ - - ">="
386
+ - !ruby/object:Gem::Version
387
+ version: '0'
388
+ requirements: []
389
+ rubyforge_project:
390
+ rubygems_version: 2.4.5
391
+ signing_key:
392
+ specification_version: 4
393
+ summary: Sandoz skin for BBMB
394
+ test_files:
395
+ - test/rcov
396
+ - test/selenium.rb
397
+ - test/selenium/selenium-server.jar
398
+ - test/selenium/test_current_order.rb
399
+ - test/selenium/test_customer.rb
400
+ - test/selenium/test_customers.rb
401
+ - test/selenium/test_favorites.rb
402
+ - test/selenium/test_favorites_result.rb
403
+ - test/selenium/test_history.rb
404
+ - test/selenium/test_login.rb
405
+ - test/selenium/test_orders.rb
406
+ - test/selenium/test_result.rb
407
+ - test/selenium/unit.rb
408
+ - test/stub/http_server.rb
409
+ - test/stub/persistence.rb
410
+ - test/suite.rb
411
+ - test/util/data/Artikel.TXT
412
+ - test/util/data/Kunden.TXT
413
+ - test/util/test_csv_importer.rb
414
+ has_rdoc: