brand2csv 0.3.1 → 0.3.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +26 -0
  5. data/Gemfile +4 -0
  6. data/History.txt +121 -0
  7. data/LICENCE.txt +515 -0
  8. data/Manifest.txt +54 -0
  9. data/README.md +27 -0
  10. data/Rakefile +18 -0
  11. data/bin/brand2csv +100 -0
  12. data/brand2csv.gemspec +44 -0
  13. data/lib/brand2csv.rb +594 -0
  14. data/lib/brand2csv/version.rb +3 -0
  15. data/logs/aspen_08_08_1986.html +598 -0
  16. data/logs/post.rohdaten.httpfox +1 -0
  17. data/logs/post.rohdaten.mechanize +1 -0
  18. data/logs/protocol_swissreg.log +86 -0
  19. data/logs/result_01.10.2005.jsp +598 -0
  20. data/logs/sr1.jsp +449 -0
  21. data/logs/sr3.jsp +598 -0
  22. data/logs/start.jsp +350 -0
  23. data/logs/start2.jsp +434 -0
  24. data/protocol.2013.05.12.textile +56 -0
  25. data/protocol.2013.05.15.textile +49 -0
  26. data/protocol.2013.05.21.textile +84 -0
  27. data/spec/brand2csv_spec.rb +62 -0
  28. data/spec/csv_spec.rb +57 -0
  29. data/spec/data/aspectra/detail_00001_P-480296.html +531 -0
  30. data/spec/data/aspectra/detail_00002_P-482236.html +531 -0
  31. data/spec/data/aspectra/detail_00003_641074.html +539 -0
  32. data/spec/data/aspectra/first_results.html +600 -0
  33. data/spec/data/einfache_suche.html +434 -0
  34. data/spec/data/erweiterte_suche.html +446 -0
  35. data/spec/data/main.html +350 -0
  36. data/spec/data/result_short.html +606 -0
  37. data/spec/data/resultate_1.html +446 -0
  38. data/spec/data/resultate_2.html +446 -0
  39. data/spec/data/urner_wildheu/detail_00001_57862.2013.html +516 -0
  40. data/spec/data/urner_wildheu/first_results.html +598 -0
  41. data/spec/data/vereinfachte_1.html +847 -0
  42. data/spec/data/vereinfachte_detail_33.html +516 -0
  43. data/spec/detail_spec.rb +28 -0
  44. data/spec/short_spec.rb +55 -0
  45. data/spec/simple_search.rb +43 -0
  46. data/spec/spec_helper.rb +34 -0
  47. data/spec/support/core_ext/kernel.rb +26 -0
  48. data/spec/support/server_mock_helper.rb +143 -0
  49. data/spec/swissreg_spec.rb +45 -0
  50. data/spec/trademark_numbers_spec.rb +21 -0
  51. data/spec/utilities_spec.rb +83 -0
  52. data/spike.rb +491 -0
  53. data/spike_mechanize_swissreg.rb +312 -0
  54. data/spike_watir.rb +58 -0
  55. data/swissreg.rb +75 -0
  56. metadata +86 -7
@@ -0,0 +1,28 @@
1
+ #encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ include Brand2csv
5
+
6
+ describe 'Detail' do
7
+ before :each do
8
+ dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
9
+ session = Swissreg.new("01.01.1990", 'Branding')
10
+ filename = "#{dataDir}/vereinfachte_detail_33.html"
11
+ expect(File.exists?(filename)).to be_truthy
12
+ doc = Nokogiri::Slop(File.open(filename))
13
+ @marke = Swissreg::getMarkenInfoFromDetail(doc)
14
+ end
15
+
16
+ it "collected trademark information must be correct" do
17
+ expect(@marke).not_to be_nil
18
+ expect(@marke.zeile_1).to eq("Peter Löcker Bauart")
19
+ expect(@marke.zeile_2).to eq("Trollstrasse 20")
20
+ expect(@marke.zeile_3).to be_nil
21
+ expect(@marke.plz).to eq('8400')
22
+ expect(@marke.ort).to eq('Winterthur')
23
+ expect(@marke.markennummer).to eq('00135/2013')
24
+ expect(@marke.inhaber).to eq("Peter Löcker Bauart, Trollstrasse 20, 8400 Winterthur")
25
+ expect(@marke.name).to eq('https://www.swissreg.ch/srclient/images/loadImage?Action=LoadImg&ItemType=tm&ImageType=print&ImageHash=F431E13A9D8F363BD06604796634142A18A5BA7C.jpeg')
26
+ end
27
+
28
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ include Brand2csv
4
+
5
+ describe 'Short (e.g. corvatsch*)' do
6
+ TrademarkSearch = 'TRADEMARK REGISTER SEARCH TIMES: QUERY=[10] SELECT=[70] SERVER=[80] DELEGATE=[93] (HITS=[9])'
7
+ before :each do
8
+ dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
9
+ session = Swissreg.new("01.01.1990", 'Branding')
10
+ filename = "#{dataDir}/result_short.html"
11
+ expect(File.exists?(filename)).to be_truthy
12
+ doc = Nokogiri::Slop(File.open(filename))
13
+ @einfach = Swissreg::Vereinfachte.new(doc)
14
+ end
15
+
16
+ it "short search must return info about trademark search" do
17
+ expect(Swissreg::inputValue(@einfach.inputData, 'id_swissreg:mainContent:vivian')).to eq(TrademarkSearch)
18
+ end
19
+
20
+ it "short search must return hit information" do
21
+ expect(@einfach.firstHit).to eq(1)
22
+ expect(@einfach.nrHits).to eq(9)
23
+ end
24
+
25
+ it "short search must return details" do
26
+ expect(@einfach.links2details).not_to be_nil
27
+ expect(@einfach.links2details.size).to eq(9)
28
+ expect(@einfach.links2details.index(901614)).not_to be_nil
29
+ end
30
+
31
+ it "short search must return information about (sub-)pages" do
32
+ expect(@einfach.pageNr).to eq(1)
33
+ expect(@einfach.nrSubPages).to eq(1)
34
+ end
35
+
36
+ it "short search getPostDataForSubpage" do
37
+ expect(@einfach.pageNr).to eq(1)
38
+ data = @einfach.getPostDataForSubpage(2)
39
+ expect(data).not_to be_nil
40
+ expect(Swissreg::inputValue(data, 'tmMainId')).to eq("")
41
+ expect(Swissreg::inputValue(data, 'id_swissreg:mainContent:scroll_1')).to eq("idx2")
42
+ expect(Swissreg::inputValue(data, 'id_swissreg:_idcl')).to eq('id_swissreg:mainContent:scroll_1idx2')
43
+ end
44
+
45
+ it "short search getPostDataForDetail" do
46
+ expect(@einfach.pageNr).to eq(1)
47
+ position = 3
48
+ id = 937439
49
+ data = @einfach.getPostDataForDetail(position, id)
50
+ expect(data).not_to be_nil
51
+ expect(Swissreg::inputValue(data, 'tmMainId')).to eq("#{id}")
52
+ expect(Swissreg::inputValue(data, 'id_swissreg:mainContent:scroll_1')).to eq('')
53
+ expect(Swissreg::inputValue(data, 'id_swissreg:_idcl')).to eq("id_swissreg:mainContent:data:#{position}:tm_no_detail:id_detail")
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ include Brand2csv
4
+
5
+ describe 'simple search with > 500 results' do
6
+ TrademarkSearch = 'TRADEMARK REGISTER SEARCH TIMES: QUERY=[530] SELECT=[1456] SERVER=[1991] DELEGATE=[2088] (HITS=[6349])'
7
+
8
+ before :each do
9
+ dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
10
+ session = Swissreg.new("01.01.1990", 'Branding')
11
+ filename = "#{dataDir}/vereinfachte_1.html"
12
+ expect(File.exists?(filename)).to be_truthy
13
+ doc = Nokogiri::Slop(File.open(filename))
14
+ @einfach = Swissreg::Vereinfachte.new(doc)
15
+ end
16
+
17
+ it "simple search must contain inputData with vivian" do
18
+ data = @einfach.inputData
19
+ expect(data.class).to eq(Array)
20
+ expect(data.size).to eq(9)
21
+ end
22
+
23
+ it "simple search must return info about trademark search" do
24
+ expect(Swissreg::inputValue(@einfach.inputData, 'id_swissreg:mainContent:vivian')).to eq(TrademarkSearch)
25
+ end
26
+
27
+ it "simple search must return hit information" do
28
+ expect(@einfach.firstHit).to eq(1)
29
+ expect(@einfach.nrHits).to eq(6349)
30
+ end
31
+
32
+ it "simple search must return details" do
33
+ expect(@einfach.links2details).not_to be_nil
34
+ expect(@einfach.links2details.size).to eq(250)
35
+ expect(@einfach.links2details.index(940377)).not_to be_nil
36
+ end
37
+
38
+ it "simple search must return information about (sub-)pages" do
39
+ expect(@einfach.pageNr).to eq(1)
40
+ expect(@einfach.nrSubPages).to eq(26)
41
+ end
42
+
43
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ require 'bundler/setup'
6
+ Bundler.require
7
+
8
+ require 'rspec'
9
+ require "webmock/rspec"
10
+
11
+ Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
12
+
13
+ require 'brand2csv'
14
+ begin
15
+ capture(:stdout) { load File.expand_path("../../bin/brand2csv", __FILE__) }
16
+ rescue LoadError
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.treat_symbols_as_metadata_keys_with_true_values = true
21
+ config.run_all_when_everything_filtered = true
22
+ config.filter_run :focus
23
+ config.filter_run_excluding :slow
24
+ #config.exclusion_filter = {:slow => true}
25
+
26
+ # Run specs in random order to surface order dependencies. If you find an
27
+ # order dependency and want to debug it, you can fix the order by providing
28
+ # the seed, which is printed after each run.
29
+ # --seed 1234
30
+ config.order = 'random'
31
+
32
+ # Helper
33
+ config.include(ServerMockHelper)
34
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'stringio'
4
+ require 'ostruct'
5
+
6
+ module Kernel
7
+ # for stdout/stderr
8
+ def capture(stream)
9
+ begin
10
+ stream = stream.to_s
11
+ eval "$#{stream} = StringIO.new"
12
+ yield
13
+ result = eval("$#{stream}").string
14
+ ensure
15
+ eval "$#{stream} = #{stream.upcase}"
16
+ end
17
+ result
18
+ end
19
+
20
+ alias :original_exit :exit
21
+ # for load executable file
22
+ def exit(status=false)
23
+ (status == 1) ? raise(LoadError) : original_exit
24
+ end
25
+ end
26
+
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module ServerMockHelper
5
+
6
+ def setup_swissreg_ch_server(trademark, timespan, result_folder, trademark_ids)
7
+ # main
8
+ stub_response = File.read(File.expand_path("../../data/main.html", __FILE__))
9
+ stub_request(:get, "https://www.swissreg.ch/srclient/faces/jsp/start.jsp").
10
+ with(
11
+ :headers => {
12
+ "Accept" => "*/*",
13
+ "Host" => "www.swissreg.ch",
14
+ }).
15
+ to_return(
16
+ :status => 200,
17
+ :headers => {"Content-Type" => 'text/html; charset=utf-8'},
18
+ :body => stub_response)
19
+ # erweiterte
20
+ stub_response = File.read(File.expand_path("../../data/erweiterte_suche.html", __FILE__))
21
+ stub_request(:post, "https://www.swissreg.ch/srclient/faces/jsp/start.jsp").
22
+ with(
23
+ :headers => {
24
+ "Accept" => "*/*",
25
+ "Host" => "www.swissreg.ch",
26
+ },
27
+ :body => {
28
+ "autoScroll" => "",
29
+ "id_swissreg:_idcl" => "id_swissreg_sub_nav_ipiNavigation_item0",
30
+ "id_swissreg:_link_hidden_" => "",
31
+ "id_swissreg_SUBMIT" => "1",
32
+ "javax.faces.ViewState" =>"rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQADi9qc3Avc3RhcnQuanNw"
33
+ }).
34
+ to_return(
35
+ :status => 200,
36
+ :headers => {"Content-Type" => 'text/html; charset=utf-8'},
37
+ :body => stub_response)
38
+ # result page 1
39
+ stub_response = File.read(File.expand_path("../../data/#{result_folder}/first_results.html", __FILE__))
40
+ stub_request(:post, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr3.jsp").
41
+ with(
42
+ :headers => {
43
+ "Accept" => "*/*",
44
+ "Host" => "www.swissreg.ch",
45
+ },
46
+ :body => {
47
+ "autoScroll" => "0,829",
48
+ "id_swissreg:_idcl" => "",
49
+ "id_swissreg:_link_hidden_" => "",
50
+ "id_swissreg:mainContent:id_cbxCountry" => "_ALL",
51
+ "id_swissreg:mainContent:id_cbxFormatChoice" => "1",
52
+ "id_swissreg:mainContent:id_cbxHitsPerPage" => "250",
53
+ "id_swissreg:mainContent:id_cbxTMColorClaim" => "_ALL",
54
+ "id_swissreg:mainContent:id_cbxTMForm" => "_ALL",
55
+ "id_swissreg:mainContent:id_cbxTMTypeGrp" => "_ALL",
56
+ "id_swissreg:mainContent:id_ckbTMChoice" => "tm_lbl_app_date",
57
+ "id_swissreg:mainContent:id_ckbTMPubReason" => "8",
58
+ "id_swissreg:mainContent:id_ckbTMState" => "3",
59
+ "id_swissreg:mainContent:id_txf_agent" => "",
60
+ "id_swissreg:mainContent:id_txf_appDate" => "#{timespan}",
61
+ "id_swissreg:mainContent:id_txf_app_no" => "",
62
+ "id_swissreg:mainContent:id_txf_applicant" => "",
63
+ "id_swissreg:mainContent:id_txf_expiryDate" => "",
64
+ "id_swissreg:mainContent:id_txf_licensee" => "",
65
+ "id_swissreg:mainContent:id_txf_nizza_class" => "",
66
+ "id_swissreg:mainContent:id_txf_pub_date" => "",
67
+ "id_swissreg:mainContent:id_txf_tm_no" => "",
68
+ "id_swissreg:mainContent:id_txf_tm_text" => "#{trademark}",
69
+ "id_swissreg:mainContent:sub_fieldset:id_submit" => "suchen",
70
+ "id_swissreg_SUBMIT" => "1",
71
+ "javax.faces.ViewState" => "rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQADi9qc3Avc3RhcnQuanNw"
72
+ }).
73
+ to_return(
74
+ :status => 200,
75
+ :headers => {"Content-Type" => 'text/html; charset=utf-8'},
76
+ :body => stub_response)
77
+ # result page 2
78
+ stub_response = File.read(File.expand_path("../../data/#{result_folder}/first_results.html", __FILE__))
79
+ stub_request(:post, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr3.jsp").
80
+ with(
81
+ :headers => {
82
+ "Accept" => "*/*",
83
+ "Host" => "www.swissreg.ch",
84
+ },
85
+ :body => {
86
+ "autoScroll" => "",
87
+ "id_swissreg:_idcl" => "id_swissreg_sub_nav_ipiNavigation_item0_item3",
88
+ "id_swissreg:_link_hidden_" => "",
89
+ "id_swissreg:mainContent:id_cbxCountry" => "_ALL",
90
+ "id_swissreg:mainContent:id_cbxFormatChoice" => "1",
91
+ "id_swissreg:mainContent:id_cbxHitsPerPage" => "25",
92
+ "id_swissreg:mainContent:id_cbxTMColorClaim" => "_ALL",
93
+ "id_swissreg:mainContent:id_cbxTMForm" => "_ALL",
94
+ "id_swissreg:mainContent:id_cbxTMTypeGrp" => "_ALL",
95
+ "id_swissreg:mainContent:id_ckbTMChoice" => "tm_lbl_applicant",
96
+ "id_swissreg:mainContent:id_ckbTMPubReason" => "8",
97
+ "id_swissreg:mainContent:id_ckbTMState" => "3",
98
+ "id_swissreg:mainContent:id_txf_agent" => "",
99
+ "id_swissreg:mainContent:id_txf_appDate" => "",
100
+ "id_swissreg:mainContent:id_txf_app_no" => "",
101
+ "id_swissreg:mainContent:id_txf_applicant" => "",
102
+ "id_swissreg:mainContent:id_txf_expiryDate" => "",
103
+ "id_swissreg:mainContent:id_txf_licensee" => "",
104
+ "id_swissreg:mainContent:id_txf_nizza_class" => "",
105
+ "id_swissreg:mainContent:id_txf_pub_date" => "",
106
+ "id_swissreg:mainContent:id_txf_tm_no" => "",
107
+ "id_swissreg:mainContent:id_txf_tm_text" => "",
108
+ "id_swissreg_SUBMIT" => "1",
109
+ "javax.faces.ViewState" => "rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAEzcHQAFi9qc3AvdHJhZGVtYXJrL3NyMy5qc3A="
110
+ }).
111
+ to_return(
112
+ :status => 200,
113
+ :headers => {"Content-Type" => 'text/html; charset=utf-8'},
114
+ :body => stub_response)
115
+
116
+ counter = 0
117
+ trademark_ids.each{
118
+ |trademark_id|
119
+ counter += 1
120
+ filename = File.expand_path("../../data/#{result_folder}/detail_#{sprintf('%05i',counter)}_#{trademark_id.sub('/','.')}.html", __FILE__)
121
+ stub_response = File.read(filename)
122
+ stub_request(:get, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr300.jsp?language=de&section=tm&id=#{trademark_id}").
123
+ with(
124
+ :headers => {
125
+ "Accept" => "*/*",
126
+ "Host" => "www.swissreg.ch",
127
+ }).
128
+ to_return(
129
+ :status => 200,
130
+ :headers => {"Content-Type" => 'text/html; charset=utf-8'},
131
+ :body => stub_response)
132
+
133
+ }
134
+ stub_request(:post, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr30.jsp").
135
+ with(:body => {"autoScroll"=>"", "id_swissreg:_idcl"=>"", "id_swissreg:_link_hidden_"=>"", "id_swissreg:mainContent:id_sub_options_result:id_ckbTMChoice"=>"tm_lbl_app_date", "id_swissreg:mainContent:id_sub_options_result:sub_fieldset:id_cbxHitsPerPage"=>"250", "id_swissreg:mainContent:scroll_1"=>"",
136
+ "id_swissreg:mainContent:vivian"=>
137
+ "TRADEMARK REGISTER SEARCH TIMES: QUERY=[14] SELECT=[20] SERVER=[37] DELEGATE=[46]", "id_swissreg_SUBMIT"=>"1", "javax.faces.ViewState"=>"rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAE0cHQAFy9qc3AvdHJhZGVtYXJrL3NyMzAuanNw", "tmMainId"=>""}
138
+ ).
139
+ to_return(:status => 200, :body => "", :headers => {})
140
+
141
+ end
142
+
143
+ end
@@ -0,0 +1,45 @@
1
+ #encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Get some simple example from swissreg' do
5
+
6
+ HasVertreterPos = 4
7
+ pending ('mocking swissreg no longer works')
8
+ if false
9
+ it "should get correct results from swissreg" do
10
+ marke = 'aspectra*'
11
+ timespan = '01.01.2012-31.12.2012'
12
+ setup_swissreg_ch_server(marke, timespan, 'aspectra', ["P-480296", "P-482236", "641074"])
13
+ results = nil
14
+ capture(:stdout) { results = Brand2csv::run(timespan, marke) }
15
+ expect(results).not_to be_nil
16
+ expect(results.size).to eq(3)
17
+ expect(results[0].zeile_1).to eq('Aspectra AG')
18
+ expect(results[0].plz).to eq('8004')
19
+ expect(results[0].ort).to eq('Zürich')
20
+ csv = "#{timespan}.csv"
21
+ csv_lines = IO.readlines(csv)
22
+ expect(csv_lines[1].split(';')[HasVertreterPos]).to eq("Ja")
23
+ expect(csv_lines[2].split(';')[HasVertreterPos]).to eq("Ja")
24
+ expect(csv_lines[3].split(';')[HasVertreterPos]).to eq("Nein")
25
+ end
26
+
27
+ it "should get correct results from swissreg when owner has two postal addresses" do
28
+ marke = 'Urner Wildheu'
29
+ timespan = '01.05.2013-30.06.2013'
30
+ setup_swissreg_ch_server(marke, timespan, 'urner_wildheu', ["57862/2013"])
31
+ results = nil
32
+ capture(:stdout) { results = Brand2csv::run(timespan, marke) }
33
+ expect(results).not_to be_nil
34
+ expect(results.size).to eq(1)
35
+ expect(results[0].zeile_1).to eq('Philipp Arnold')
36
+ expect(results[0].zeile_2).to eq('Seestrasse 37a')
37
+ expect(results[0].plz).to eq('6454')
38
+ expect(results[0].ort).to eq('Flüelen')
39
+ csv = "#{timespan}.csv"
40
+ csv_lines = IO.readlines(csv)
41
+ expect(csv_lines[1].split(';')[2]).to eq('Philipp Arnold, Seestrasse 37a, 6454 Flüelen')
42
+ expect(csv_lines[1].split(';')[HasVertreterPos]).to eq("Ja")
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Brand2csv
4
+
5
+ describe 'trademark number search' do
6
+
7
+ before :each do
8
+ dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
9
+ filename = "#{dataDir}/result_short.html"
10
+ expect(File.exists?(filename)).to be_truthy
11
+ @doc = Nokogiri::Slop(File.open(filename))
12
+ end
13
+
14
+ it "trademark number search must contain 9 numbers" do
15
+ numbers = Swissreg::getTrademarkNumbers(@doc)
16
+ expect(numbers).not_to be_nil
17
+ expect(numbers.size).to eq(9)
18
+ expect(numbers.index('00127/2011')).not_to be_nil
19
+ end
20
+
21
+ end
@@ -0,0 +1,83 @@
1
+ #encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ include Brand2csv
5
+
6
+ describe 'Tests for utility procedure' do
7
+
8
+ before :each do
9
+ @data = [
10
+ ["autoScroll", ""],
11
+ ["id_swissreg:mainContent:id_show_simple_view_hitlist", "Vereinfachte Trefferliste anzeigen"],
12
+ ["id_swissreg_SUBMIT", "1"],
13
+ ["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0"],
14
+ ["id_swissreg:_link_hidden_", ""],
15
+ ["javax.faces.ViewState", 'xzy' ],
16
+ ]
17
+ end
18
+
19
+ it "inputValue should return nil for not existing key " do
20
+ expect(Swissreg::inputValue(@data, 'xxx')).to be_nil
21
+ end
22
+
23
+ it "inputValue should return correct value for existing key " do
24
+ expect(Swissreg::inputValue(@data, 'autoScroll')).to eq('')
25
+ expect(Swissreg::inputValue(@data, 'id_swissreg:mainContent:id_show_simple_view_hitlist')).to eq("Vereinfachte Trefferliste anzeigen")
26
+ end
27
+
28
+ it "HitsPerPage must be 250" do
29
+ expect(Swissreg::HitsPerPage).to eq(250)
30
+ end
31
+
32
+ end
33
+
34
+ describe 'Tests parsing adress line' do
35
+
36
+ it "must handle correctly Via San Salvatore, 2" do
37
+ full_address_line = 'Ideal Hobby Sagl, Via San Salvatore, 2, 6902 Paradiso'
38
+ number = 'for_debugging'
39
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
40
+ expect(zeile_1).to eq('Ideal Hobby Sagl')
41
+ expect(zeile_2).to eq('Via San Salvatore, 2')
42
+ expect(zeile_3).to be_nil
43
+ expect(plz).to eq('6902')
44
+ expect(ort).to eq('Paradiso')
45
+ end
46
+
47
+ it "must handle correctly 90, route de Frontenex" do
48
+ full_address_line = 'Olivier Karim Wasem, 90, route de Frontenex, 1208 Genève'
49
+ number = 'for_debugging'
50
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
51
+ expect(zeile_1).to eq('Olivier Karim Wasem')
52
+ expect(zeile_2).to eq('90, route de Frontenex')
53
+ expect(zeile_3).to be_nil
54
+ expect(plz).to eq('1208')
55
+ expect(ort).to eq('Genève')
56
+ end
57
+
58
+ it "must handle ampersands correctly" do
59
+ full_address_line = 'Schweiz. Serum- & Impfinstitut, und Institut zur Erforschung der, Infektionskrankheiten, Rehhagstrasse 79, 3018 Bern'
60
+ number = 'for_debugging'
61
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
62
+ expect(zeile_1).to eq('Schweiz. Serum- & Impfinstitut')
63
+ expect(zeile_2).to eq('und Institut zur Erforschung der')
64
+ expect(zeile_3).to eq('Infektionskrankheiten')
65
+ expect(zeile_4).to eq('Rehhagstrasse 79')
66
+ expect(zeile_5).to be_nil
67
+ expect(plz).to eq('3018')
68
+ expect(ort).to eq('Bern')
69
+ end
70
+
71
+ it "must handle several postal addresses correctly" do
72
+ full_address_line = 'Philipp Arnold, Seestrasse 37a, 6454 Flüelen, , Peter Tresoldi, c/o Xitix GmbH, Rathausplatz 4, 6460 Altdorf'
73
+ number = 'for_debugging'
74
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
75
+ expect(zeile_1).to eq('Philipp Arnold')
76
+ expect(zeile_2).to eq('Seestrasse 37a')
77
+ expect(zeile_3).to be_nil
78
+ expect(zeile_4).to be_nil
79
+ expect(zeile_5).to be_nil
80
+ expect(plz).to eq('6454')
81
+ expect(ort).to eq('Flüelen')
82
+ end
83
+ end