-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.rb
117 lines (97 loc) · 5.08 KB
/
sample.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
require 'test_helper'
# StatementsHelper tests for search_cckg() only
class StatementsHelperSearchCckgTest < ActionView::TestCase
tests StatementsHelper
test "search_cckg: should search cckg for uris that match 100%" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should search cckg for uris that match 100%') do
expected = {:data=>[["Place des Arts - Théâtre Maisonneuve", "http://kg.artsdata.ca/resource/K11-11"]]}
actual = search_cckg "Théâtre Maisonneuve", "Place"
assert_equal expected, actual
end
end
test "search_cckg: should search cckg for uris by matching name in substring" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should search cckg for uris by matching name in substring') do
expected = {:data=>[["St. Lawrence Centre for the Arts - Bluma Appel Theatre", "http://kg.artsdata.ca/resource/K11-6"], ["Canadian Stage - Berkeley Street Theatre", "http://kg.artsdata.ca/resource/K11-14"]]}
actual = search_cckg "The locations is in the lovely Bluma Appel Theatre and Berkeley Street Theatre.", "Place"
assert_equal expected, actual
end
end
test "search_cckg: should search cckg for VaughnCo Entertainment presents" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should search cckg for VaughnCo Entertainment presents') do
expected = {data:[["VaughnCo Entertainment", "http://kg.artsdata.ca/resource/K10-148"]]}
actual = search_cckg "VaughnCo Entertainment presents", "Organization"
assert_equal expected, actual
end
end
test "search_cckg: should search cckg for Wajdi Mouawad" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should search cckg for Wajdi Mouawad') do
expected = {data:[["Wajdi Mouawad", "http://kg.artsdata.ca/resource/K12-362"]]}
actual = search_cckg "Wajdi Mouawad", "Person"
assert_equal expected, actual
end
end
test "search_cckg: should search cckg for nowhere" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should search cckg for nowhere') do
expected = {:data=>[]}
actual = search_cckg "Show is at nowhere", "Place"
assert_equal expected, actual
end
end
test "search_cckg: remove duplicates" do
VCR.use_cassette('StatementsHelperSearchCckgTest: remove duplicates') do
expected = {data:[["Canadian Stage - Berkeley Street Theatre", "http://kg.artsdata.ca/resource/K11-14"]]}
actual = search_cckg "The locations is in the lovely Berkeley Street Theatre and Canadian Stage - Berkeley Street Theatre.", "Place"
assert_equal expected, actual
end
end
# Common words: example Person name that is removed "wiL", "http://kg.artsdata.ca/resource/K12-32"
test "search_cckg: should not match names with common words" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should not match names with common words') do
expected = {data:[]}
actual = search_cckg "The word will contains part of a first name.", "Person"
assert_equal expected, actual
end
end
test "search_cckg: should match names with single neutral quote" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should match names with single neutral quote') do
expected = {:data=>[["La P'tite Église (Shippagan)", "http://kg.artsdata.ca/resource/K11-131"]]}
actual = search_cckg "Shippagan 20 h 00 La P'tite Église (Shippagan)", "Place"
assert_equal expected, actual
end
end
test "search_cckg: should match names with single curved quote" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should match names with single curved quote') do
expected = {:data=>[["Emily D’Angelo", "http://kg.artsdata.ca/resource/K12-150"]]}
actual = search_cckg "Emily D’Angelo", "Person"
assert_equal expected, actual
end
end
test "search_cckg: should match names with &" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should match names with &') do
expected = {:data=>[["meagan&amy", "http://kg.artsdata.ca/resource/K10-376"]]}
actual = search_cckg "meagan&amy", "Organization"
assert_equal expected, actual
end
end
test "search_cckg: should match places with title in French" do
VCR.use_cassette('StatementsHelperSearchCckgTest: should match places with title in French') do
expected = {:data=>[["Théâtre Marc Lescarbot", "http://kg.artsdata.ca/resource/K11-133"]]}
actual = search_cckg "Théâtre Marc Lescarbot", "Place"
assert_equal expected, actual
end
end
test "search_cckg: find alternate names" do
VCR.use_cassette('StatementsHelperSearchCckgTest: find alternate names') do
expected = {data:[["Dow Centennial Centre - Shell Theatre", "http://kg.artsdata.ca/resource/K11-64"]]}
actual = search_cckg "Shell Theatre", "Place"
assert_equal expected, actual
end
end
test "search_cckg: find additional type using artsdata" do
VCR.use_cassette('StatementsHelperSearchCckgTest: find additional types') do
expected = {data:[["Dance", "http://kg.artsdata.ca/resource/DancePerformance"]]}
actual = search_cckg("Dance", "EventType")
assert_equal expected, actual
end
end
end