exlibris-primo 0.1.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (272) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.md +111 -0
  3. data/Rakefile +2 -1
  4. data/lib/exlibris-primo.rb +4 -14
  5. data/lib/exlibris/primo.rb +13 -0
  6. data/lib/exlibris/primo/abstract.rb +28 -0
  7. data/lib/exlibris/primo/chain_gang/README.md +9 -0
  8. data/lib/exlibris/primo/chain_gang/base.rb +121 -0
  9. data/lib/exlibris/primo/chain_gang/record.rb +18 -0
  10. data/lib/exlibris/primo/chain_gang/search.rb +319 -0
  11. data/lib/exlibris/primo/chain_gang/user.rb +18 -0
  12. data/lib/exlibris/primo/config.rb +69 -0
  13. data/lib/exlibris/primo/eshelf.rb +115 -62
  14. data/lib/exlibris/primo/facet.rb +40 -0
  15. data/lib/exlibris/primo/facet_value.rb +40 -0
  16. data/lib/exlibris/primo/holding.rb +81 -152
  17. data/lib/exlibris/primo/link.rb +32 -0
  18. data/lib/exlibris/primo/namespaces.rb +44 -0
  19. data/lib/exlibris/primo/pnx/dedup_mgr.rb +91 -0
  20. data/lib/exlibris/primo/pnx/elements.rb +79 -0
  21. data/lib/exlibris/primo/pnx/frbr.rb +24 -0
  22. data/lib/exlibris/primo/pnx/holdings.rb +36 -0
  23. data/lib/exlibris/primo/pnx/links.rb +54 -0
  24. data/lib/exlibris/primo/pnx/openurl.rb +24 -0
  25. data/lib/exlibris/primo/pnx/subfields.rb +18 -0
  26. data/lib/exlibris/primo/record.rb +20 -106
  27. data/lib/exlibris/primo/request_attributes.rb +28 -0
  28. data/lib/exlibris/primo/review.rb +46 -0
  29. data/lib/exlibris/primo/reviews.rb +81 -0
  30. data/lib/exlibris/primo/search.rb +82 -0
  31. data/lib/exlibris/primo/source/aleph.rb +77 -31
  32. data/lib/exlibris/primo/tag.rb +34 -0
  33. data/lib/exlibris/primo/tags.rb +103 -0
  34. data/lib/exlibris/primo/version.rb +1 -1
  35. data/lib/exlibris/primo/web_service/client/base.rb +30 -0
  36. data/lib/exlibris/primo/web_service/client/base/endpoint.rb +29 -0
  37. data/lib/exlibris/primo/web_service/client/base/savon_client.rb +24 -0
  38. data/lib/exlibris/primo/web_service/client/base/savon_config.rb +19 -0
  39. data/lib/exlibris/primo/web_service/client/base/soap_actions.rb +55 -0
  40. data/lib/exlibris/primo/web_service/client/base/wsdl.rb +14 -0
  41. data/lib/exlibris/primo/web_service/client/eshelf.rb +22 -0
  42. data/lib/exlibris/primo/web_service/client/reviews.rb +15 -0
  43. data/lib/exlibris/primo/web_service/client/search.rb +15 -0
  44. data/lib/exlibris/primo/web_service/client/tags.rb +14 -0
  45. data/lib/exlibris/primo/web_service/request/base.rb +77 -0
  46. data/lib/exlibris/primo/web_service/request/base/base_elements.rb +71 -0
  47. data/lib/exlibris/primo/web_service/request/base/call.rb +19 -0
  48. data/lib/exlibris/primo/web_service/request/base/client.rb +45 -0
  49. data/lib/exlibris/primo/web_service/request/base/soap_action.rb +29 -0
  50. data/lib/exlibris/primo/web_service/request/eshelf.rb +71 -0
  51. data/lib/exlibris/primo/web_service/request/reviews.rb +57 -0
  52. data/lib/exlibris/primo/web_service/request/search.rb +49 -0
  53. data/lib/exlibris/primo/web_service/request/search/display_fields.rb +30 -0
  54. data/lib/exlibris/primo/web_service/request/search/languages.rb +32 -0
  55. data/lib/exlibris/primo/web_service/request/search/location.rb +15 -0
  56. data/lib/exlibris/primo/web_service/request/search/locations.rb +33 -0
  57. data/lib/exlibris/primo/web_service/request/search/query_term.rb +43 -0
  58. data/lib/exlibris/primo/web_service/request/search/query_terms.rb +40 -0
  59. data/lib/exlibris/primo/web_service/request/search/search_elements.rb +97 -0
  60. data/lib/exlibris/primo/web_service/request/search/sort_bys.rb +32 -0
  61. data/lib/exlibris/primo/web_service/request/tags.rb +56 -0
  62. data/lib/exlibris/primo/web_service/response/base.rb +28 -0
  63. data/lib/exlibris/primo/web_service/response/base/error.rb +25 -0
  64. data/lib/exlibris/primo/web_service/response/base/util.rb +19 -0
  65. data/lib/exlibris/primo/web_service/response/did_u_mean.rb +17 -0
  66. data/lib/exlibris/primo/web_service/response/eshelf.rb +68 -0
  67. data/lib/exlibris/primo/web_service/response/facets.rb +21 -0
  68. data/lib/exlibris/primo/web_service/response/records.rb +17 -0
  69. data/lib/exlibris/primo/web_service/response/reviews.rb +49 -0
  70. data/lib/exlibris/primo/web_service/response/search.rb +36 -0
  71. data/lib/exlibris/primo/web_service/response/search_stats.rb +48 -0
  72. data/lib/exlibris/primo/web_service/response/tags.rb +54 -0
  73. data/lib/exlibris/primo/write_attributes.rb +38 -0
  74. data/lib/exlibris/primo/xml_util.rb +63 -0
  75. data/test/{unit/eshelf_test.rb → bak/eshelf_test.rb.bak} +0 -0
  76. data/test/{unit/record_test.rb → bak/record_test.rb.bak} +0 -0
  77. data/test/{unit/searcher_test.rb → bak/searcher_test.rb.bak} +0 -0
  78. data/test/{unit/web_service_test.rb → bak/web_service_test.rb.bak} +0 -0
  79. data/test/config_test.rb +72 -0
  80. data/test/eshelf_test.rb +66 -0
  81. data/test/exlibris-primo_test.rb +0 -1
  82. data/test/facet_test.rb +27 -0
  83. data/test/facet_value_test.rb +62 -0
  84. data/test/holding_test.rb +26 -0
  85. data/test/link_test.rb +42 -0
  86. data/test/pnx/dedup_mgr_test.rb +16 -0
  87. data/test/pnx/elements_test.rb +16 -0
  88. data/test/pnx/frbr_test.rb +12 -0
  89. data/test/pnx/holdings_test.rb +53 -0
  90. data/test/pnx/links_test.rb +44 -0
  91. data/test/pnx/openurl_test.rb +10 -0
  92. data/test/record_test.rb +11 -0
  93. data/test/review_test.rb +15 -0
  94. data/test/reviews_test.rb +50 -0
  95. data/test/search_test.rb +328 -0
  96. data/test/source/aleph_test.rb +52 -0
  97. data/test/support/config.yml +35 -0
  98. data/test/tag_test.rb +12 -0
  99. data/test/tags_test.rb +65 -0
  100. data/test/test_helper.rb +536 -4
  101. data/test/vcr_cassettes/client_action_no_arguments.yml +38 -0
  102. data/test/vcr_cassettes/client_get_all_my_reviews.yml +49 -0
  103. data/test/vcr_cassettes/client_get_all_my_tags.yml +49 -0
  104. data/test/vcr_cassettes/client_get_eshelf.yml +13812 -0
  105. data/test/vcr_cassettes/client_get_record.yml +222 -0
  106. data/test/vcr_cassettes/client_get_reviews.yml +39 -0
  107. data/test/vcr_cassettes/client_get_tags.yml +42 -0
  108. data/test/vcr_cassettes/client_search_brief_isbn.yml +288 -0
  109. data/test/vcr_cassettes/client_search_brief_issn.yml +282 -0
  110. data/test/vcr_cassettes/client_too_many_arguments.yml +38 -0
  111. data/test/vcr_cassettes/eshelf.yml +13845 -0
  112. data/test/vcr_cassettes/eshelf_add_folder.yml +109 -0
  113. data/test/vcr_cassettes/eshelf_add_record.yml +14237 -0
  114. data/test/vcr_cassettes/eshelf_add_records.yml +14156 -0
  115. data/test/vcr_cassettes/eshelf_basket_id.yml +36 -0
  116. data/test/vcr_cassettes/eshelf_records.yml +13460 -0
  117. data/test/vcr_cassettes/eshelf_remove_folder.yml +76 -0
  118. data/test/vcr_cassettes/eshelf_remove_record.yml +13500 -0
  119. data/test/vcr_cassettes/eshelf_remove_records.yml +13741 -0
  120. data/test/vcr_cassettes/{web_service_single_document.yml → remote_record_call.yml} +12 -23
  121. data/test/vcr_cassettes/{searcher_dedupmrg_by_id.yml → remote_record_dedupmgr.yml} +19 -31
  122. data/test/vcr_cassettes/request_add_folder_to_eshelf.yml +43 -0
  123. data/test/vcr_cassettes/request_add_to_eshelf.yml +43 -0
  124. data/test/vcr_cassettes/request_did_u_mean_enabled.yml +48 -0
  125. data/test/vcr_cassettes/request_full_view.yml +222 -0
  126. data/test/vcr_cassettes/request_get_eshelf.yml +13812 -0
  127. data/test/vcr_cassettes/request_get_eshelf_structure.yml +36 -0
  128. data/test/vcr_cassettes/request_get_reviews.yml +39 -0
  129. data/test/vcr_cassettes/request_get_tags.yml +42 -0
  130. data/test/vcr_cassettes/request_remove_folder_from_eshelf.yml +43 -0
  131. data/test/vcr_cassettes/request_remove_from_eshelf.yml +43 -0
  132. data/test/vcr_cassettes/request_search_author.yml +1258 -0
  133. data/test/vcr_cassettes/request_search_did_u_mean.yml +48 -0
  134. data/test/vcr_cassettes/request_search_genre.yml +1321 -0
  135. data/test/vcr_cassettes/request_search_isbn.yml +288 -0
  136. data/test/vcr_cassettes/request_search_issn.yml +282 -0
  137. data/test/vcr_cassettes/request_search_locations.yml +288 -0
  138. data/test/vcr_cassettes/request_search_title.yml +1024 -0
  139. data/test/vcr_cassettes/request_search_title_author_genre.yml +708 -0
  140. data/test/vcr_cassettes/response_add_folder_to_eshelf.yml +43 -0
  141. data/test/vcr_cassettes/response_add_review.yml +39 -0
  142. data/test/vcr_cassettes/response_add_tag.yml +39 -0
  143. data/test/vcr_cassettes/response_add_to_eshelf.yml +43 -0
  144. data/test/vcr_cassettes/response_did_u_mean_disabled.yml +46 -0
  145. data/test/vcr_cassettes/response_did_u_mean_enabled.yml +48 -0
  146. data/test/vcr_cassettes/response_full_view.yml +222 -0
  147. data/test/vcr_cassettes/response_get_all_my_reviews.yml +49 -0
  148. data/test/vcr_cassettes/response_get_all_my_tags.yml +49 -0
  149. data/test/vcr_cassettes/response_get_eshelf.yml +13633 -0
  150. data/test/vcr_cassettes/response_get_eshelf_structure.yml +36 -0
  151. data/test/vcr_cassettes/response_get_reviews.yml +39 -0
  152. data/test/vcr_cassettes/response_get_reviews_by_rating.yml +49 -0
  153. data/test/vcr_cassettes/response_get_reviews_for_record.yml +39 -0
  154. data/test/vcr_cassettes/response_get_tags.yml +42 -0
  155. data/test/vcr_cassettes/response_get_tags_for_record.yml +42 -0
  156. data/test/vcr_cassettes/response_remove_folder_from_eshelf.yml +43 -0
  157. data/test/vcr_cassettes/response_remove_from_eshelf.yml +43 -0
  158. data/test/vcr_cassettes/response_remove_review.yml +39 -0
  159. data/test/vcr_cassettes/response_remove_tag.yml +39 -0
  160. data/test/vcr_cassettes/response_remove_user_tags.yml +39 -0
  161. data/test/vcr_cassettes/response_search.yml +288 -0
  162. data/test/vcr_cassettes/response_search_did_u_mean.yml +48 -0
  163. data/test/vcr_cassettes/reviews.yml +49 -0
  164. data/test/vcr_cassettes/reviews_add_review.yml +39 -0
  165. data/test/vcr_cassettes/reviews_check_empty_reviews_first.yml +39 -0
  166. data/test/vcr_cassettes/reviews_check_empty_reviews_last.yml +39 -0
  167. data/test/vcr_cassettes/reviews_rating.yml +168 -0
  168. data/test/vcr_cassettes/reviews_record.yml +49 -0
  169. data/test/vcr_cassettes/reviews_remove_review.yml +39 -0
  170. data/test/vcr_cassettes/reviews_reviews.yml +49 -0
  171. data/test/vcr_cassettes/reviews_user.yml +58 -0
  172. data/test/vcr_cassettes/search_chaining_author_title.yml +938 -0
  173. data/test/vcr_cassettes/search_chaining_contains_any.yml +1453 -0
  174. data/test/vcr_cassettes/search_chaining_contains_author_starts_with_title.yml +1055 -0
  175. data/test/vcr_cassettes/search_chaining_isbn.yml +288 -0
  176. data/test/vcr_cassettes/search_chaining_page_size_author.yml +5933 -0
  177. data/test/vcr_cassettes/search_did_u_mean.yml +48 -0
  178. data/test/vcr_cassettes/search_enable_highlighting.yml +1337 -0
  179. data/test/vcr_cassettes/search_isbn.yml +288 -0
  180. data/test/vcr_cassettes/search_languages.yml +1332 -0
  181. data/test/vcr_cassettes/search_locations.yml +1440 -0
  182. data/test/vcr_cassettes/search_record_id.yml +222 -0
  183. data/test/vcr_cassettes/search_record_id_chaining.yml +222 -0
  184. data/test/vcr_cassettes/search_sort_by.yml +1289 -0
  185. data/test/vcr_cassettes/search_sort_by_locations.yml +1387 -0
  186. data/test/vcr_cassettes/tags.yml +56 -0
  187. data/test/vcr_cassettes/tags_add_extra_tag.yml +39 -0
  188. data/test/vcr_cassettes/tags_add_tag.yml +39 -0
  189. data/test/vcr_cassettes/tags_add_tags.yml +111 -0
  190. data/test/vcr_cassettes/tags_check_1_tags.yml +56 -0
  191. data/test/vcr_cassettes/tags_check_2_tags.yml +68 -0
  192. data/test/vcr_cassettes/tags_check_empty_tags_first.yml +42 -0
  193. data/test/vcr_cassettes/tags_check_empty_tags_last.yml +42 -0
  194. data/test/vcr_cassettes/tags_remove_tag.yml +39 -0
  195. data/test/vcr_cassettes/tags_remove_tags.yml +111 -0
  196. data/test/vcr_cassettes/tags_remove_user_tags.yml +39 -0
  197. data/test/vcr_cassettes/tags_tags.yml +104 -0
  198. data/test/vcr_cassettes/tags_user.yml +73 -0
  199. data/test/web_service/client/abstract_test.rb +29 -0
  200. data/test/web_service/client/eshelf_test.rb +22 -0
  201. data/test/web_service/client/reviews_test.rb +31 -0
  202. data/test/web_service/client/savon_client_test.rb +17 -0
  203. data/test/web_service/client/search_benchmarks.rb +29 -0
  204. data/test/web_service/client/search_test.rb +44 -0
  205. data/test/web_service/client/soap_actions_test.rb +45 -0
  206. data/test/web_service/client/tags_test.rb +31 -0
  207. data/test/web_service/request/abstract_test.rb +68 -0
  208. data/test/web_service/request/base_elements_test.rb +231 -0
  209. data/test/web_service/request/build_xml_test.rb +23 -0
  210. data/test/web_service/request/client_test.rb +53 -0
  211. data/test/web_service/request/eshelf_test.rb +26 -0
  212. data/test/web_service/request/location_test.rb +25 -0
  213. data/test/web_service/request/query_term_test.rb +29 -0
  214. data/test/web_service/request/reviews_test.rb +27 -0
  215. data/test/web_service/request/search_test.rb +234 -0
  216. data/test/web_service/request/soap_action_test.rb +120 -0
  217. data/test/web_service/request/tags_test.rb +27 -0
  218. data/test/web_service/response/abstract_test.rb +200 -0
  219. data/test/web_service/response/did_u_mean_test.rb +44 -0
  220. data/test/web_service/response/error_test.rb +31 -0
  221. data/test/web_service/response/eshelf_test.rb +28 -0
  222. data/test/web_service/response/facets_test.rb +42 -0
  223. data/test/web_service/response/records_test.rb +56 -0
  224. data/test/web_service/response/reviews_test.rb +28 -0
  225. data/test/web_service/response/search_stats_test.rb +75 -0
  226. data/test/web_service/response/search_test.rb +40 -0
  227. data/test/web_service/response/tags_test.rb +28 -0
  228. data/test/xml_util_test.rb +23 -0
  229. metadata +456 -114
  230. data/README.rdoc +0 -68
  231. data/lib/exlibris/primo/related_link.rb +0 -20
  232. data/lib/exlibris/primo/rsrc.rb +0 -20
  233. data/lib/exlibris/primo/searcher.rb +0 -277
  234. data/lib/exlibris/primo/toc.rb +0 -20
  235. data/lib/exlibris/primo/web_service.rb +0 -203
  236. data/test/unit/searcher_benchmarks.rb +0 -74
  237. data/test/unit/web_service_benchmarks.rb +0 -58
  238. data/test/vcr_cassettes/eshelf_add_invalid_records.yml +0 -107
  239. data/test/vcr_cassettes/eshelf_add_same_record_twice.yml +0 -159
  240. data/test/vcr_cassettes/eshelf_add_to_empty_basket.yml +0 -107
  241. data/test/vcr_cassettes/eshelf_add_to_invalid_basket.yml +0 -55
  242. data/test/vcr_cassettes/eshelf_invalid_eshelf.yml +0 -55
  243. data/test/vcr_cassettes/eshelf_invalid_institution.yml +0 -55
  244. data/test/vcr_cassettes/eshelf_valid_eshelf.yml +0 -2553
  245. data/test/vcr_cassettes/eshelf_valid_eshelf_structure.yml +0 -47
  246. data/test/vcr_cassettes/record.yml +0 -212
  247. data/test/vcr_cassettes/record_invalid_record.yml +0 -55
  248. data/test/vcr_cassettes/record_sub_record.yml +0 -212
  249. data/test/vcr_cassettes/record_valid_record.yml +0 -212
  250. data/test/vcr_cassettes/searcher_base_holdings_by_id.yml +0 -212
  251. data/test/vcr_cassettes/searcher_diacritics1_by_id.yml +0 -207
  252. data/test/vcr_cassettes/searcher_diacritics2_by_id.yml +0 -232
  253. data/test/vcr_cassettes/searcher_holdings_by_id.yml +0 -212
  254. data/test/vcr_cassettes/searcher_invalid_id.yml +0 -55
  255. data/test/vcr_cassettes/searcher_rsrcs_by_id.yml +0 -270
  256. data/test/vcr_cassettes/searcher_search_by_isbn.yml +0 -278
  257. data/test/vcr_cassettes/searcher_search_by_issn.yml +0 -297
  258. data/test/vcr_cassettes/searcher_search_by_title_author_genre.yml +0 -671
  259. data/test/vcr_cassettes/searcher_test_bug_1361.yml +0 -224
  260. data/test/vcr_cassettes/searcher_test_problem_by_id.yml +0 -194
  261. data/test/vcr_cassettes/searcher_tocs_by_id.yml +0 -217
  262. data/test/vcr_cassettes/web_service_author_search.yml +0 -1269
  263. data/test/vcr_cassettes/web_service_bogus_200.yml +0 -392
  264. data/test/vcr_cassettes/web_service_brief_search.yml +0 -299
  265. data/test/vcr_cassettes/web_service_get_eshelf.yml +0 -11823
  266. data/test/vcr_cassettes/web_service_get_eshelf_structure_search.yml +0 -47
  267. data/test/vcr_cassettes/web_service_invalid_document.yml +0 -54
  268. data/test/vcr_cassettes/web_service_isbn_search.yml +0 -299
  269. data/test/vcr_cassettes/web_service_issn_search.yml +0 -293
  270. data/test/vcr_cassettes/web_service_problem_document.yml +0 -193
  271. data/test/vcr_cassettes/web_service_title_author_genre_search.yml +0 -719
  272. data/test/vcr_cassettes/web_service_title_search.yml +0 -1035
@@ -0,0 +1,17 @@
1
+ module WebService
2
+ module Client
3
+ require 'test_helper'
4
+ class SavonClientTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ end
8
+
9
+ def test_nonexistent_soap_action
10
+ VCR.use_cassette('client nonexistent soap action') do
11
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
12
+ assert_kind_of Savon::Client, client.send(:client)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module WebService
2
+ module Client
3
+ require 'test_helper'
4
+ class SearchBenchmarks < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ @doc_id = "nyu_aleph000062856"
8
+ @isbn = "0143039008"
9
+ @issn = "0090-5720"
10
+ @title = "Travels with My Aunt"
11
+ @author = "Graham Greene"
12
+ @genre = "Book"
13
+ end
14
+
15
+ def test_benchmarks
16
+ VCR.turn_off!
17
+ Benchmark.bmbm do |results|
18
+ results.report("Web Service Search:") {
19
+ (1..10).each {
20
+ search = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
21
+ response = search.search_brief "<request><![CDATA[<searchRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><PrimoSearchRequest xmlns=\"http://www.exlibris.com/primo/xsd/search/request\"><QueryTerms><BoolOpeator>AND</BoolOpeator><QueryTerm><IndexField>isbn</IndexField><PrecisionOperator>exact</PrecisionOperator><Value>0090-5720</Value></QueryTerm></QueryTerms><StartIndex>1</StartIndex><BulkSize>5</BulkSize><DidUMeanEnabled>false</DidUMeanEnabled></PrimoSearchRequest><institution>NYU</institution></searchRequest>]]></request>"
22
+ }
23
+ }
24
+ end
25
+ VCR.turn_on!
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ module WebService
2
+ module Client
3
+ require 'test_helper'
4
+ class SearchTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ @doc_id = "nyu_aleph000062856"
8
+ @isbn = "0143039008"
9
+ @issn = "0090-5720"
10
+ @title = "Travels with My Aunt"
11
+ @author = "Graham Greene"
12
+ @genre = "Book"
13
+ @institution = "NYU"
14
+ end
15
+
16
+ def test_search_brief_by_issn
17
+ assert_nothing_raised {
18
+ VCR.use_cassette('client search brief issn') do
19
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
20
+ response = client.search_brief "<request><![CDATA[<searchRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><PrimoSearchRequest xmlns=\"http://www.exlibris.com/primo/xsd/search/request\"><QueryTerms><BoolOpeator>AND</BoolOpeator><QueryTerm><IndexField>isbn</IndexField><PrecisionOperator>exact</PrecisionOperator><Value>0090-5720</Value></QueryTerm></QueryTerms><StartIndex>1</StartIndex><BulkSize>5</BulkSize><DidUMeanEnabled>false</DidUMeanEnabled></PrimoSearchRequest><institution>NYU</institution></searchRequest>]]></request>"
21
+ end
22
+ }
23
+ end
24
+
25
+ def test_search_brief_by_isnn
26
+ assert_nothing_raised {
27
+ VCR.use_cassette('client search brief isbn') do
28
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
29
+ response = client.search_brief "<request><![CDATA[<searchRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><PrimoSearchRequest xmlns=\"http://www.exlibris.com/primo/xsd/search/request\"><QueryTerms><BoolOpeator>AND</BoolOpeator><QueryTerm><IndexField>isbn</IndexField><PrecisionOperator>exact</PrecisionOperator><Value>0143039008</Value></QueryTerm></QueryTerms><StartIndex>1</StartIndex><BulkSize>5</BulkSize><DidUMeanEnabled>false</DidUMeanEnabled></PrimoSearchRequest><institution>NYU</institution></searchRequest>]]></request>"
30
+ end
31
+ }
32
+ end
33
+
34
+ def test_get_record
35
+ assert_nothing_raised {
36
+ VCR.use_cassette('client get record') do
37
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
38
+ response = client.get_record "<request><![CDATA[<fullViewRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><PrimoSearchRequest xmlns=\"http://www.exlibris.com/primo/xsd/search/request\"><QueryTerms><BoolOpeator>AND</BoolOpeator></QueryTerms><StartIndex>1</StartIndex><BulkSize>5</BulkSize><DidUMeanEnabled>false</DidUMeanEnabled></PrimoSearchRequest><institution>NYU</institution><docId>nyu_aleph000062856</docId></fullViewRequest>]]></request>"
39
+ end
40
+ }
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,45 @@
1
+ module WebService
2
+ module Client
3
+ require 'test_helper'
4
+ class SoapActionsTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ end
8
+
9
+ def test_respond_to
10
+ VCR.use_cassette('client nonexistent method') do
11
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
12
+ assert(client.respond_to? :get_record)
13
+ assert((not client.respond_to?(:nonexistent_action)))
14
+ end
15
+ end
16
+
17
+ def test_nonexistent_action
18
+ VCR.use_cassette('client nonexistent method') do
19
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
20
+ assert_raise(NoMethodError) {
21
+ client.nonexistent_action
22
+ }
23
+ end
24
+ end
25
+
26
+ def test_no_arguments
27
+ VCR.use_cassette('client action no arguments') do
28
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
29
+ assert_raise(ArgumentError, Savon::SOAP::Fault) {
30
+ client.get_record
31
+ }
32
+ end
33
+ end
34
+
35
+ def test_too_many_arguments
36
+ VCR.use_cassette('client too many arguments') do
37
+ client = Exlibris::Primo::WebService::Client::Search.new :base_url => @base_url
38
+ assert_raise(ArgumentError, Savon::SOAP::Fault) {
39
+ client.get_record "1", "2"
40
+ }
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ module WebService
2
+ module Client
3
+ require 'test_helper'
4
+ class TagsTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ @doc_id = "nyu_aleph000062856"
8
+ @user_id = "N12162279"
9
+ @institution = "NYU"
10
+ end
11
+
12
+ def test_get_tags
13
+ assert_nothing_raised {
14
+ VCR.use_cassette('client get tags') do
15
+ client = Exlibris::Primo::WebService::Client::Tags.new :base_url => @base_url
16
+ response = client.get_tags "<request><![CDATA[<getTagsRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><institution>NYU</institution><docId>nyu_aleph000062856</docId><userId>N12162279</userId></getTagsRequest>]]></request>"
17
+ end
18
+ }
19
+ end
20
+
21
+ def test_get_all_my_tags
22
+ assert_nothing_raised {
23
+ VCR.use_cassette('client get all my tags') do
24
+ client = Exlibris::Primo::WebService::Client::Tags.new :base_url => @base_url
25
+ response = client.get_all_my_tags "<request><![CDATA[<getAllMyTagsRequest xmlns=\"http://www.exlibris.com/primo/xsd/wsRequest\" xmlns:uic=\"http://www.exlibris.com/primo/xsd/primoview/uicomponents\"><institution>NYU</institution><userId>N12162279</userId></getAllMyTagsRequest>]]></request>"
26
+ end
27
+ }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,68 @@
1
+ module WebService
2
+ module Request
3
+ require 'test_helper'
4
+ class AbstractTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ @user_id = "N12162279"
8
+ @institution = "NYU"
9
+ @doc_id = "nyu_aleph000062856"
10
+ @dedupmgr_id = "dedupmrg17343091"
11
+ end
12
+
13
+ def test_abstract_raise
14
+ assert_raise(NotImplementedError) {
15
+ Exlibris::Primo::WebService::Request::Base.new
16
+ }
17
+ assert_raise(NotImplementedError) {
18
+ Exlibris::Primo::WebService::Request::User.new
19
+ }
20
+ assert_raise(NotImplementedError) {
21
+ Exlibris::Primo::WebService::Request::Record.new
22
+ }
23
+ assert_raise(NotImplementedError) {
24
+ Exlibris::Primo::WebService::Request::UserRecord.new
25
+ }
26
+ assert_raise(NotImplementedError) {
27
+ Exlibris::Primo::WebService::Request::Eshelf.new
28
+ }
29
+ assert_raise(NotImplementedError) {
30
+ Exlibris::Primo::WebService::Request::EshelfStructure.new
31
+ }
32
+ assert_raise(NotImplementedError) {
33
+ Exlibris::Primo::WebService::Request::EshelfRecord.new
34
+ }
35
+ assert_raise(NotImplementedError) {
36
+ Exlibris::Primo::WebService::Request::Reviews.new
37
+ }
38
+ assert_raise(NotImplementedError) {
39
+ Exlibris::Primo::WebService::Request::Tags.new
40
+ }
41
+ end
42
+
43
+ def test_non_abstract_nothing_raised
44
+ assert_nothing_raised {
45
+ Exlibris::Primo::WebService::Request::AddFolderToEshelf.new
46
+ Exlibris::Primo::WebService::Request::GetEshelfStructure.new
47
+ Exlibris::Primo::WebService::Request::GetEshelf.new
48
+ Exlibris::Primo::WebService::Request::AddToEshelf.new
49
+ Exlibris::Primo::WebService::Request::RemoveFromEshelf.new
50
+ Exlibris::Primo::WebService::Request::GetReviews.new
51
+ Exlibris::Primo::WebService::Request::GetAllMyReviews.new
52
+ Exlibris::Primo::WebService::Request::GetReviewsForRecord.new
53
+ Exlibris::Primo::WebService::Request::GetReviewsByRating.new
54
+ Exlibris::Primo::WebService::Request::AddReview.new
55
+ Exlibris::Primo::WebService::Request::RemoveReview.new
56
+ Exlibris::Primo::WebService::Request::GetTags.new
57
+ Exlibris::Primo::WebService::Request::GetAllMyTags.new
58
+ Exlibris::Primo::WebService::Request::GetTagsForRecord.new
59
+ Exlibris::Primo::WebService::Request::AddTag.new
60
+ Exlibris::Primo::WebService::Request::RemoveTag.new
61
+ Exlibris::Primo::WebService::Request::RemoveUserTags.new
62
+ Exlibris::Primo::WebService::Request::Search.new
63
+ Exlibris::Primo::WebService::Request::FullView.new
64
+ }
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,231 @@
1
+ module WebService
2
+ module Request
3
+ require 'test_helper'
4
+ class BaseElementsTest < Test::Unit::TestCase
5
+ def setup
6
+ @base_url = "http://bobcatdev.library.nyu.edu"
7
+ @institution = "University"
8
+ @ip = "127.0.0.1"
9
+ @group = "Department"
10
+ @on_campus = "true"
11
+ @is_logged_in = "true"
12
+ @pds_handle = "pds_handle_dummy"
13
+ @user_id = "user_id_dummy"
14
+ @folder_id = "folder_id_dummy"
15
+ @doc_id = "doc_id_dummy"
16
+ @folder_name = "new folder, dummy"
17
+ @parent_folder = "parent_folder_dummy"
18
+ @search_key = "search_key_dummy"
19
+ end
20
+
21
+ def test_base_base_elements
22
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle],
23
+ Exlibris::Primo::WebService::Request::Base.base_elements
24
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id],
25
+ Exlibris::Primo::WebService::Request::User.base_elements
26
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id],
27
+ Exlibris::Primo::WebService::Request::Record.base_elements
28
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
29
+ Exlibris::Primo::WebService::Request::UserRecord.base_elements
30
+ end
31
+
32
+ def test_eshelf_base_elements
33
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id],
34
+ Exlibris::Primo::WebService::Request::Eshelf.base_elements
35
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id, :doc_id],
36
+ Exlibris::Primo::WebService::Request::EshelfRecord.base_elements
37
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id, :include_basket_items],
38
+ Exlibris::Primo::WebService::Request::GetEshelfStructure.base_elements
39
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_name, :parent_folder],
40
+ Exlibris::Primo::WebService::Request::AddFolderToEshelf.base_elements
41
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id, :get_delivery],
42
+ Exlibris::Primo::WebService::Request::GetEshelf.base_elements
43
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :doc_id, :searchkey],
44
+ Exlibris::Primo::WebService::Request::AddToEshelf.base_elements
45
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id, :doc_id],
46
+ Exlibris::Primo::WebService::Request::RemoveFromEshelf.base_elements
47
+ end
48
+
49
+ def test_new_eshelf_base_elements
50
+ #
51
+ # The eshelf structure action is not specified in Primo's WSDL and
52
+ # is therefore not supported for the time being.
53
+ #
54
+ # assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :folder_id, :include_basket_items],
55
+ # Exlibris::Primo::WebService::Request::GetEshelfStructure.base_elements
56
+ assert_nothing_raised {
57
+ request = Exlibris::Primo::WebService::Request::AddFolderToEshelf.new(
58
+ :institution => @institution,
59
+ :ip => @ip,
60
+ :group => @group,
61
+ :on_campus => @on_campus,
62
+ :is_logged_in => @is_logged_in,
63
+ :pds_handle => @pds_handle,
64
+ :user_id => @user_id,
65
+ :folder_name => @folder_name,
66
+ :parent_folder => @parent_folder
67
+ )
68
+ assert_equal "<institution>University</institution>"+
69
+ "<ip>127.0.0.1</ip>"+
70
+ "<group>Department</group>"+
71
+ "<onCampus>true</onCampus>"+
72
+ "<isLoggedIn>true</isLoggedIn>"+
73
+ "<pdsHandle>pds_handle_dummy</pdsHandle>"+
74
+ "<userId>user_id_dummy</userId>"+
75
+ "<folderName>new folder, dummy</folderName>"+
76
+ "<parentFolder>parent_folder_dummy</parentFolder>", request.send(:base_elements_xml)
77
+ }
78
+ assert_nothing_raised {
79
+ request = Exlibris::Primo::WebService::Request::GetEshelf.new(
80
+ :institution => @institution,
81
+ :ip => @ip,
82
+ :group => @group,
83
+ :on_campus => @on_campus,
84
+ :is_logged_in => @is_logged_in,
85
+ :pds_handle => @pds_handle,
86
+ :user_id => @user_id,
87
+ :folder_id => @folder_id
88
+ )
89
+ assert_equal "<institution>University</institution>"+
90
+ "<ip>127.0.0.1</ip>"+
91
+ "<group>Department</group>"+
92
+ "<onCampus>true</onCampus>"+
93
+ "<isLoggedIn>true</isLoggedIn>"+
94
+ "<pdsHandle>pds_handle_dummy</pdsHandle>"+
95
+ "<userId>user_id_dummy</userId>"+
96
+ "<folderId>folder_id_dummy</folderId>", request.send(:base_elements_xml)
97
+ }
98
+ assert_nothing_raised {
99
+ request = Exlibris::Primo::WebService::Request::AddToEshelf.new(
100
+ :institution => @institution,
101
+ :ip => @ip,
102
+ :group => @group,
103
+ :on_campus => @on_campus,
104
+ :is_logged_in => @is_logged_in,
105
+ :pds_handle => @pds_handle,
106
+ :user_id => @user_id,
107
+ :doc_id => @doc_id,
108
+ :searchkey => @search_key
109
+ )
110
+ assert_equal "<institution>University</institution>"+
111
+ "<ip>127.0.0.1</ip>"+
112
+ "<group>Department</group>"+
113
+ "<onCampus>true</onCampus>"+
114
+ "<isLoggedIn>true</isLoggedIn>"+
115
+ "<pdsHandle>pds_handle_dummy</pdsHandle>"+
116
+ "<userId>user_id_dummy</userId>"+
117
+ "<docId>doc_id_dummy</docId>"+
118
+ "<searchkey>search_key_dummy</searchkey>", request.send(:base_elements_xml)
119
+ }
120
+ assert_nothing_raised {
121
+ request = Exlibris::Primo::WebService::Request::RemoveFromEshelf.new(
122
+ :institution => @institution,
123
+ :ip => @ip,
124
+ :group => @group,
125
+ :on_campus => @on_campus,
126
+ :is_logged_in => @is_logged_in,
127
+ :pds_handle => @pds_handle,
128
+ :user_id => @user_id,
129
+ :folder_id => @folder_id,
130
+ :doc_id => @doc_id
131
+ )
132
+ assert_equal "<institution>University</institution>"+
133
+ "<ip>127.0.0.1</ip>"+
134
+ "<group>Department</group>"+
135
+ "<onCampus>true</onCampus>"+
136
+ "<isLoggedIn>true</isLoggedIn>"+
137
+ "<pdsHandle>pds_handle_dummy</pdsHandle>"+
138
+ "<userId>user_id_dummy</userId>"+
139
+ "<folderId>folder_id_dummy</folderId>"+
140
+ "<docId>doc_id_dummy</docId>", request.send(:base_elements_xml)
141
+ }
142
+ end
143
+
144
+ def test_search_base_elements
145
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle],
146
+ Exlibris::Primo::WebService::Request::Search.base_elements
147
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id],
148
+ Exlibris::Primo::WebService::Request::FullView.base_elements
149
+ end
150
+
151
+ def test_new_search_base_elements
152
+ assert_nothing_raised {
153
+ request = Exlibris::Primo::WebService::Request::Search.new(
154
+ :institution => @institution,
155
+ :ip => @ip,
156
+ :group => @group,
157
+ :on_campus => @on_campus,
158
+ :is_logged_in => @is_logged_in,
159
+ :pds_handle => @pds_handle
160
+ )
161
+ assert_equal "<institution>University</institution>"+
162
+ "<ip>127.0.0.1</ip>"+
163
+ "<group>Department</group>"+
164
+ "<onCampus>true</onCampus>"+
165
+ "<isLoggedIn>true</isLoggedIn>"+
166
+ "<pdsHandle>pds_handle_dummy</pdsHandle>", request.send(:base_elements_xml)
167
+ }
168
+ assert_nothing_raised {
169
+ request = Exlibris::Primo::WebService::Request::FullView.new(
170
+ :institution => @institution,
171
+ :ip => @ip,
172
+ :group => @group,
173
+ :on_campus => @on_campus,
174
+ :is_logged_in => @is_logged_in,
175
+ :pds_handle => @pds_handle,
176
+ :doc_id => @doc_id
177
+ )
178
+ assert_equal "<institution>University</institution>"+
179
+ "<ip>127.0.0.1</ip>"+
180
+ "<group>Department</group>"+
181
+ "<onCampus>true</onCampus>"+
182
+ "<isLoggedIn>true</isLoggedIn>"+
183
+ "<pdsHandle>pds_handle_dummy</pdsHandle>"+
184
+ "<docId>doc_id_dummy</docId>", request.send(:base_elements_xml)
185
+ }
186
+ end
187
+
188
+ def test_reviews_base_elements
189
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
190
+ Exlibris::Primo::WebService::Request::Reviews.base_elements
191
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
192
+ Exlibris::Primo::WebService::Request::GetReviews.base_elements
193
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id],
194
+ Exlibris::Primo::WebService::Request::GetAllMyReviews.base_elements
195
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id],
196
+ Exlibris::Primo::WebService::Request::GetReviewsForRecord.base_elements
197
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id, :rating],
198
+ Exlibris::Primo::WebService::Request::GetReviewsByRating.base_elements
199
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id, :value, :rating, :user_display_name, :allow_user_name, :status],
200
+ Exlibris::Primo::WebService::Request::AddReview.base_elements
201
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
202
+ Exlibris::Primo::WebService::Request::RemoveReview.base_elements
203
+ end
204
+
205
+ def test_tags_base_elements
206
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
207
+ Exlibris::Primo::WebService::Request::Tags.base_elements
208
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id],
209
+ Exlibris::Primo::WebService::Request::GetTags.base_elements
210
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id],
211
+ Exlibris::Primo::WebService::Request::GetAllMyTags.base_elements
212
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id],
213
+ Exlibris::Primo::WebService::Request::GetTagsForRecord.base_elements
214
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :doc_id, :user_id, :value],
215
+ Exlibris::Primo::WebService::Request::RemoveTag.base_elements
216
+ assert_equal [:institution, :ip, :group, :on_campus, :is_logged_in, :pds_handle, :user_id],
217
+ Exlibris::Primo::WebService::Request::RemoveUserTags.base_elements
218
+ end
219
+
220
+ def test_undefined_base_elements
221
+ assert_nothing_raised {
222
+ Exlibris::Primo::WebService::Request::GetEshelf.new(:not_a_base_element => "")
223
+ }
224
+ request = Exlibris::Primo::WebService::Request::GetEshelf.new
225
+ assert_raise(NoMethodError) {
226
+ request.not_a_base_element = ""
227
+ }
228
+ end
229
+ end
230
+ end
231
+ end