ramaze.ch.oddb.org 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. data/History.txt +6 -0
  2. data/LICENSE +339 -0
  3. data/Manifest.txt +285 -0
  4. data/README.txt +45 -0
  5. data/Rakefile +28 -0
  6. data/bin/admin +69 -0
  7. data/bin/exportd +63 -0
  8. data/bin/migrate +461 -0
  9. data/bin/oddbd +62 -0
  10. data/data/fulltext/data/dicts/french/fulltext.aff +1057 -0
  11. data/data/fulltext/data/dicts/french/fulltext.dict +91189 -0
  12. data/data/fulltext/data/dicts/french/fulltext.stop +135 -0
  13. data/data/fulltext/data/dicts/german/fulltext.aff +1233 -0
  14. data/data/fulltext/data/dicts/german/fulltext.dict +287574 -0
  15. data/data/fulltext/data/dicts/german/fulltext.stop +133 -0
  16. data/data/fulltext/data/german_compound/README +15 -0
  17. data/data/fulltext/data/german_compound/compound.pl +63 -0
  18. data/data/fulltext/data/german_compound/german.stop +20 -0
  19. data/data/fulltext/data/ispell-german-compound.tar.gz +0 -0
  20. data/data/fulltext/redist/dict_french/Makefile +12 -0
  21. data/data/fulltext/redist/dict_french/README.french +1 -0
  22. data/data/fulltext/redist/dict_french/dict_french.sql.in +7 -0
  23. data/data/fulltext/redist/dict_french/dict_snowball.c +56 -0
  24. data/data/fulltext/redist/dict_french/french_stem.c +1222 -0
  25. data/data/fulltext/redist/dict_french/french_stem.h +16 -0
  26. data/data/fulltext/redist/dict_french/subinclude.h +2 -0
  27. data/data/fulltext/redist/dict_german/Makefile +12 -0
  28. data/data/fulltext/redist/dict_german/README.german +1 -0
  29. data/data/fulltext/redist/dict_german/dict_german.sql.in +7 -0
  30. data/data/fulltext/redist/dict_german/dict_snowball.c +56 -0
  31. data/data/fulltext/redist/dict_german/german_stem.c +527 -0
  32. data/data/fulltext/redist/dict_german/german_stem.h +16 -0
  33. data/data/fulltext/redist/dict_german/subinclude.h +1 -0
  34. data/data/fulltext/redist/french_stem.c +1222 -0
  35. data/data/fulltext/redist/french_stem.h +16 -0
  36. data/data/fulltext/redist/german_stem.c +527 -0
  37. data/data/fulltext/redist/german_stem.h +16 -0
  38. data/lib/fixes/ruby19.rb +21 -0
  39. data/lib/fixes/selenium.rb +20 -0
  40. data/lib/fixes/singular.rb +8 -0
  41. data/lib/fixes/yaml.rb +13 -0
  42. data/lib/oddb.rb +11 -0
  43. data/lib/oddb/business/company.rb +18 -0
  44. data/lib/oddb/business/invoice.rb +75 -0
  45. data/lib/oddb/business/price.rb +60 -0
  46. data/lib/oddb/config.rb +73 -0
  47. data/lib/oddb/drugs.rb +16 -0
  48. data/lib/oddb/drugs/active_agent.rb +37 -0
  49. data/lib/oddb/drugs/atc.rb +53 -0
  50. data/lib/oddb/drugs/composition.rb +41 -0
  51. data/lib/oddb/drugs/ddd.rb +24 -0
  52. data/lib/oddb/drugs/dose.rb +107 -0
  53. data/lib/oddb/drugs/galenic_form.rb +21 -0
  54. data/lib/oddb/drugs/galenic_group.rb +17 -0
  55. data/lib/oddb/drugs/package.rb +87 -0
  56. data/lib/oddb/drugs/part.rb +56 -0
  57. data/lib/oddb/drugs/product.rb +25 -0
  58. data/lib/oddb/drugs/sequence.rb +61 -0
  59. data/lib/oddb/drugs/substance.rb +31 -0
  60. data/lib/oddb/drugs/substance_group.rb +13 -0
  61. data/lib/oddb/drugs/unit.rb +12 -0
  62. data/lib/oddb/export.rb +4 -0
  63. data/lib/oddb/export/csv.rb +89 -0
  64. data/lib/oddb/export/l10n_sessions.rb +30 -0
  65. data/lib/oddb/export/rss.rb +44 -0
  66. data/lib/oddb/export/server.rb +58 -0
  67. data/lib/oddb/export/xls.rb +119 -0
  68. data/lib/oddb/export/yaml.rb +123 -0
  69. data/lib/oddb/html/state/drugs/admin/package.rb +189 -0
  70. data/lib/oddb/html/state/drugs/admin/product.rb +56 -0
  71. data/lib/oddb/html/state/drugs/admin/sequence.rb +259 -0
  72. data/lib/oddb/html/state/drugs/ajax/explain_ddd_price.rb +19 -0
  73. data/lib/oddb/html/state/drugs/ajax/explain_price.rb +19 -0
  74. data/lib/oddb/html/state/drugs/ajax/global.rb +18 -0
  75. data/lib/oddb/html/state/drugs/ajax/package_infos.rb +19 -0
  76. data/lib/oddb/html/state/drugs/ajax/remote_infos.rb +19 -0
  77. data/lib/oddb/html/state/drugs/atc_browser.rb +39 -0
  78. data/lib/oddb/html/state/drugs/atc_guidelines.rb +21 -0
  79. data/lib/oddb/html/state/drugs/compare.rb +52 -0
  80. data/lib/oddb/html/state/drugs/download_export.rb +18 -0
  81. data/lib/oddb/html/state/drugs/fachinfo.rb +21 -0
  82. data/lib/oddb/html/state/drugs/feedback.rb +94 -0
  83. data/lib/oddb/html/state/drugs/global.rb +266 -0
  84. data/lib/oddb/html/state/drugs/init.rb +18 -0
  85. data/lib/oddb/html/state/drugs/login.rb +17 -0
  86. data/lib/oddb/html/state/drugs/package.rb +32 -0
  87. data/lib/oddb/html/state/drugs/patinfo.rb +21 -0
  88. data/lib/oddb/html/state/drugs/products.rb +51 -0
  89. data/lib/oddb/html/state/drugs/result.rb +125 -0
  90. data/lib/oddb/html/state/global.rb +165 -0
  91. data/lib/oddb/html/state/global_predefine.rb +17 -0
  92. data/lib/oddb/html/state/limit.rb +17 -0
  93. data/lib/oddb/html/state/login.rb +56 -0
  94. data/lib/oddb/html/state/paypal/checkout.rb +130 -0
  95. data/lib/oddb/html/state/paypal/collect.rb +46 -0
  96. data/lib/oddb/html/state/paypal/redirect.rb +18 -0
  97. data/lib/oddb/html/state/register_export.rb +38 -0
  98. data/lib/oddb/html/state/register_poweruser.rb +17 -0
  99. data/lib/oddb/html/state/viral/admin.rb +76 -0
  100. data/lib/oddb/html/state/viral/poweruser.rb +16 -0
  101. data/lib/oddb/html/util/annotated_list.rb +39 -0
  102. data/lib/oddb/html/util/know_it_all.rb +28 -0
  103. data/lib/oddb/html/util/known_user.rb +55 -0
  104. data/lib/oddb/html/util/lookandfeel.rb +554 -0
  105. data/lib/oddb/html/util/need_all_input.rb +29 -0
  106. data/lib/oddb/html/util/session.rb +88 -0
  107. data/lib/oddb/html/util/sort.rb +72 -0
  108. data/lib/oddb/html/util/unsaved_helper.rb +20 -0
  109. data/lib/oddb/html/util/validator.rb +54 -0
  110. data/lib/oddb/html/view/ajax/json.rb +22 -0
  111. data/lib/oddb/html/view/alpha_header.rb +28 -0
  112. data/lib/oddb/html/view/document.rb +126 -0
  113. data/lib/oddb/html/view/drugs/admin/package.rb +237 -0
  114. data/lib/oddb/html/view/drugs/admin/product.rb +104 -0
  115. data/lib/oddb/html/view/drugs/admin/sequence.rb +312 -0
  116. data/lib/oddb/html/view/drugs/ajax/explain_ddd_price.rb +87 -0
  117. data/lib/oddb/html/view/drugs/ajax/explain_price.rb +61 -0
  118. data/lib/oddb/html/view/drugs/ajax/package_infos.rb +105 -0
  119. data/lib/oddb/html/view/drugs/ajax/remote_infos.rb +44 -0
  120. data/lib/oddb/html/view/drugs/atc_browser.rb +68 -0
  121. data/lib/oddb/html/view/drugs/atc_guidelines.rb +94 -0
  122. data/lib/oddb/html/view/drugs/compare.rb +95 -0
  123. data/lib/oddb/html/view/drugs/download_export.rb +28 -0
  124. data/lib/oddb/html/view/drugs/fachinfo.rb +46 -0
  125. data/lib/oddb/html/view/drugs/feedback.rb +231 -0
  126. data/lib/oddb/html/view/drugs/init.rb +51 -0
  127. data/lib/oddb/html/view/drugs/legend.rb +24 -0
  128. data/lib/oddb/html/view/drugs/package.rb +398 -0
  129. data/lib/oddb/html/view/drugs/patinfo.rb +46 -0
  130. data/lib/oddb/html/view/drugs/products.rb +97 -0
  131. data/lib/oddb/html/view/drugs/result.rb +296 -0
  132. data/lib/oddb/html/view/drugs/search.rb +33 -0
  133. data/lib/oddb/html/view/drugs/template.rb +15 -0
  134. data/lib/oddb/html/view/foot.rb +52 -0
  135. data/lib/oddb/html/view/google.rb +23 -0
  136. data/lib/oddb/html/view/google_ads.rb +40 -0
  137. data/lib/oddb/html/view/head.rb +78 -0
  138. data/lib/oddb/html/view/limit.rb +109 -0
  139. data/lib/oddb/html/view/list.rb +59 -0
  140. data/lib/oddb/html/view/login.rb +38 -0
  141. data/lib/oddb/html/view/navigation.rb +67 -0
  142. data/lib/oddb/html/view/offset_header.rb +35 -0
  143. data/lib/oddb/html/view/paypal/collect.rb +84 -0
  144. data/lib/oddb/html/view/paypal/redirect.rb +51 -0
  145. data/lib/oddb/html/view/paypal/register_form.rb +106 -0
  146. data/lib/oddb/html/view/register_export.rb +29 -0
  147. data/lib/oddb/html/view/register_poweruser.rb +29 -0
  148. data/lib/oddb/html/view/rss/feedback.rb +64 -0
  149. data/lib/oddb/html/view/rss_preview.rb +54 -0
  150. data/lib/oddb/html/view/search.rb +104 -0
  151. data/lib/oddb/html/view/snapback.rb +24 -0
  152. data/lib/oddb/html/view/template.rb +56 -0
  153. data/lib/oddb/import/excel.rb +45 -0
  154. data/lib/oddb/import/import.rb +39 -0
  155. data/lib/oddb/import/rtf.rb +410 -0
  156. data/lib/oddb/import/whocc.rb +173 -0
  157. data/lib/oddb/import/xml.rb +15 -0
  158. data/lib/oddb/model.rb +179 -0
  159. data/lib/oddb/persistence/odba.rb +33 -0
  160. data/lib/oddb/persistence/odba/business/company.rb +13 -0
  161. data/lib/oddb/persistence/odba/business/invoice.rb +15 -0
  162. data/lib/oddb/persistence/odba/drugs/atc.rb +15 -0
  163. data/lib/oddb/persistence/odba/drugs/galenic_form.rb +18 -0
  164. data/lib/oddb/persistence/odba/drugs/galenic_group.rb +13 -0
  165. data/lib/oddb/persistence/odba/drugs/package.rb +25 -0
  166. data/lib/oddb/persistence/odba/drugs/product.rb +13 -0
  167. data/lib/oddb/persistence/odba/drugs/sequence.rb +21 -0
  168. data/lib/oddb/persistence/odba/drugs/substance.rb +21 -0
  169. data/lib/oddb/persistence/odba/drugs/substance_group.rb +13 -0
  170. data/lib/oddb/persistence/odba/drugs/unit.rb +13 -0
  171. data/lib/oddb/persistence/odba/export.rb +26 -0
  172. data/lib/oddb/persistence/odba/model.rb +68 -0
  173. data/lib/oddb/persistence/odba/regulatory/authority.rb +13 -0
  174. data/lib/oddb/persistence/odba/regulatory/registration.rb +13 -0
  175. data/lib/oddb/persistence/odba/text/document.rb +11 -0
  176. data/lib/oddb/persistence/odba/util/code.rb +11 -0
  177. data/lib/oddb/persistence/odba/util/m10l_document.rb +13 -0
  178. data/lib/oddb/persistence/og.rb +16 -0
  179. data/lib/oddb/persistence/og/drugs/composition.rb +14 -0
  180. data/lib/oddb/persistence/og/drugs/product.rb +14 -0
  181. data/lib/oddb/persistence/og/drugs/sequence.rb +15 -0
  182. data/lib/oddb/persistence/og/model.rb +25 -0
  183. data/lib/oddb/persistence/og/util/multilingual.rb +13 -0
  184. data/lib/oddb/redist/rtf_tools/reader.rb +139 -0
  185. data/lib/oddb/regulatory/authority.rb +14 -0
  186. data/lib/oddb/regulatory/registration.rb +15 -0
  187. data/lib/oddb/remote/business/company.rb +23 -0
  188. data/lib/oddb/remote/drugs/active_agent.rb +27 -0
  189. data/lib/oddb/remote/drugs/atc.rb +32 -0
  190. data/lib/oddb/remote/drugs/dose.rb +8 -0
  191. data/lib/oddb/remote/drugs/galenic_form.rb +25 -0
  192. data/lib/oddb/remote/drugs/package.rb +126 -0
  193. data/lib/oddb/remote/drugs/part.rb +30 -0
  194. data/lib/oddb/remote/drugs/product.rb +19 -0
  195. data/lib/oddb/remote/drugs/sequence.rb +46 -0
  196. data/lib/oddb/remote/drugs/substance.rb +20 -0
  197. data/lib/oddb/remote/drugs/unit.rb +19 -0
  198. data/lib/oddb/remote/object.rb +36 -0
  199. data/lib/oddb/remote/text/document.rb +20 -0
  200. data/lib/oddb/remote/util/m10l_document.rb +22 -0
  201. data/lib/oddb/text/chapter.rb +27 -0
  202. data/lib/oddb/text/document.rb +43 -0
  203. data/lib/oddb/text/format.rb +37 -0
  204. data/lib/oddb/text/paragraph.rb +58 -0
  205. data/lib/oddb/text/picture.rb +93 -0
  206. data/lib/oddb/text/table.rb +68 -0
  207. data/lib/oddb/util.rb +8 -0
  208. data/lib/oddb/util/annotated_list.rb +37 -0
  209. data/lib/oddb/util/code.rb +69 -0
  210. data/lib/oddb/util/comparison.rb +36 -0
  211. data/lib/oddb/util/exporter.rb +8 -0
  212. data/lib/oddb/util/feedback.rb +23 -0
  213. data/lib/oddb/util/ipn.rb +48 -0
  214. data/lib/oddb/util/m10l_document.rb +38 -0
  215. data/lib/oddb/util/mail.rb +73 -0
  216. data/lib/oddb/util/money.rb +60 -0
  217. data/lib/oddb/util/multilingual.rb +70 -0
  218. data/lib/oddb/util/quanty.rb +4 -0
  219. data/lib/oddb/util/quanty/fact.rb +229 -0
  220. data/lib/oddb/util/quanty/main.rb +160 -0
  221. data/lib/oddb/util/quanty/parse.rb +853 -0
  222. data/lib/oddb/util/quanty/units.dump +0 -0
  223. data/lib/oddb/util/server.rb +117 -0
  224. data/lib/oddb/util/updater.rb +41 -0
  225. data/lib/oddb/util/ydim.rb +110 -0
  226. data/lib/oddb/util/yus.rb +46 -0
  227. data/test/business/test_company.rb +29 -0
  228. data/test/business/test_price.rb +46 -0
  229. data/test/drugs/test_active_agent.rb +53 -0
  230. data/test/drugs/test_atc.rb +54 -0
  231. data/test/drugs/test_composition.rb +88 -0
  232. data/test/drugs/test_ddd.rb +22 -0
  233. data/test/drugs/test_dose.rb +190 -0
  234. data/test/drugs/test_galenic_form.rb +41 -0
  235. data/test/drugs/test_package.rb +173 -0
  236. data/test/drugs/test_part.rb +32 -0
  237. data/test/drugs/test_product.rb +31 -0
  238. data/test/drugs/test_sequence.rb +140 -0
  239. data/test/drugs/test_substance.rb +51 -0
  240. data/test/drugs/test_substance_group.rb +27 -0
  241. data/test/export/test_rss.rb +94 -0
  242. data/test/export/test_server.rb +117 -0
  243. data/test/export/test_xls.rb +152 -0
  244. data/test/export/test_yaml.rb +120 -0
  245. data/test/import/data/html/whocc/A.html +56 -0
  246. data/test/import/data/html/whocc/A03.html +48 -0
  247. data/test/import/data/html/whocc/A03AB.html +48 -0
  248. data/test/import/data/html/whocc/A06AA.html +47 -0
  249. data/test/import/data/html/whocc/C03.html +47 -0
  250. data/test/import/data/html/whocc/login.html +77 -0
  251. data/test/import/data/xml/ATC_2006.xml +47 -0
  252. data/test/import/data/xml/ATC_2006_ddd.xml +35 -0
  253. data/test/import/test_excel.rb +34 -0
  254. data/test/import/test_rtf.rb +40 -0
  255. data/test/import/test_whocc.rb +315 -0
  256. data/test/remote/drugs/test_active_agent.rb +36 -0
  257. data/test/selenium/selenium-server.jar +0 -0
  258. data/test/selenium/test_atc_browser.rb +122 -0
  259. data/test/selenium/test_atc_guidelines.rb +96 -0
  260. data/test/selenium/test_collect.rb +138 -0
  261. data/test/selenium/test_compare.rb +206 -0
  262. data/test/selenium/test_fachinfo.rb +130 -0
  263. data/test/selenium/test_feedback.rb +196 -0
  264. data/test/selenium/test_init.rb +52 -0
  265. data/test/selenium/test_limit.rb +305 -0
  266. data/test/selenium/test_login.rb +67 -0
  267. data/test/selenium/test_package.rb +512 -0
  268. data/test/selenium/test_patinfo.rb +131 -0
  269. data/test/selenium/test_product.rb +80 -0
  270. data/test/selenium/test_products.rb +142 -0
  271. data/test/selenium/test_search.rb +715 -0
  272. data/test/selenium/test_sequence.rb +543 -0
  273. data/test/selenium/unit.rb +185 -0
  274. data/test/stub/http_server.rb +169 -0
  275. data/test/stub/model.rb +173 -0
  276. data/test/suite.rb +15 -0
  277. data/test/test_model.rb +83 -0
  278. data/test/util/test_code.rb +74 -0
  279. data/test/util/test_ipn.rb +117 -0
  280. data/test/util/test_mail.rb +86 -0
  281. data/test/util/test_multilingual.rb +97 -0
  282. data/test/util/test_server.rb +48 -0
  283. data/test/util/test_updater.rb +353 -0
  284. data/test/util/test_ydim.rb +115 -0
  285. data/test/util/test_yus.rb +79 -0
  286. metadata +418 -0
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Selenium::TestPatinfo -- de.oddb.org -- 18.04.2008 -- hwyss@ywesee.com
4
+
5
+
6
+ $: << File.expand_path('..', File.dirname(__FILE__))
7
+
8
+ require 'selenium/unit'
9
+ require 'stub/model'
10
+ require 'oddb/drugs'
11
+ require 'oddb/util'
12
+ require 'oddb/text/chapter'
13
+ require 'oddb/text/document'
14
+
15
+ module ODDB
16
+ module Selenium
17
+ class TestPatinfo < Test::Unit::TestCase
18
+ include Selenium::TestCase
19
+ def setup
20
+ Drugs::Package.instances.clear
21
+ super
22
+ end
23
+ def setup_package(pzn='12345')
24
+ product = Drugs::Product.new
25
+ company = Business::Company.new
26
+ company.name.de = 'Producer AG'
27
+ product.company = company
28
+ product.name.de = "Amantadin by Producer"
29
+ company.save
30
+ sequence = Drugs::Sequence.new
31
+ sequence.atc = Drugs::Atc.new('N04BB01')
32
+ sequence.atc.name.de = 'Amantadin'
33
+ ddd = Drugs::Ddd.new('O')
34
+ ddd.dose = Drugs::Dose.new(5, 'mg')
35
+ sequence.atc.add_ddd(ddd)
36
+ sequence.product = product
37
+ composition = Drugs::Composition.new
38
+ composition.equivalence_factor = '44.6'
39
+ sequence.add_composition(composition)
40
+ substance = Drugs::Substance.new
41
+ substance.name.de = "Amantadin"
42
+ dose = Drugs::Dose.new(100, 'mg')
43
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
44
+ composition.add_active_agent(active_agent)
45
+ package = Drugs::Package.new
46
+ code = Util::Code.new(:festbetragsstufe, 3, 'CH')
47
+ package.add_code(code)
48
+ code = Util::Code.new(:zuzahlungsbefreit, true, 'CH')
49
+ package.add_code(code)
50
+ code = Util::Code.new(:prescription, true, 'CH')
51
+ package.add_code(code)
52
+ code = Util::Code.new(:cid, pzn, 'CH')
53
+ package.add_code(code)
54
+ part = Drugs::Part.new
55
+ part.composition = composition
56
+ part.package = package
57
+ part.size = 5
58
+ unit = Drugs::Unit.new
59
+ unit.name.de = 'Ampullen'
60
+ part.unit = unit
61
+ part.quantity = Drugs::Dose.new(20, 'ml')
62
+ package.name.de = 'Amantadin by Producer'
63
+ package.sequence = sequence
64
+ package.add_price(Business::Price.new(:public, 'CH', 6))
65
+ package.add_price(Business::Price.new(:festbetrag, 'CH', 10))
66
+ package.save
67
+ package
68
+ end
69
+ def setup_patinfo
70
+ document = Text::Document.new
71
+ chapter = Text::Chapter.new('name')
72
+ paragraph = Text::Paragraph.new
73
+ paragraph.set_format("b")
74
+ paragraph << "1. Bezeichnung"
75
+ chapter.add_paragraph paragraph
76
+ paragraph = Text::Paragraph.new
77
+ paragraph << "Amantadin Product"
78
+ chapter.add_paragraph paragraph
79
+ document.add_chapter(chapter)
80
+ chapter = Text::Chapter.new('composition')
81
+ paragraph = Text::Paragraph.new
82
+ paragraph.set_format("b")
83
+ paragraph << "2. Zusammensetzung"
84
+ chapter.add_paragraph paragraph
85
+ table = Text::Table.new
86
+ table << "Für Kinder"
87
+ table.next_cell!
88
+ table << "Für Erwachsene"
89
+ table.next_row!
90
+ table << "10 mg Amantadin pro Tablette"
91
+ table.next_cell!
92
+ table << "100 mg Amantadin pro Tablette"
93
+ chapter.add_paragraph table
94
+ document.add_chapter(chapter)
95
+ chapter = Text::Chapter.new('packaging')
96
+ paragraph = Text::Paragraph.new
97
+ paragraph.set_format("b")
98
+ paragraph << "6.1"
99
+ paragraph.set_format()
100
+ paragraph << " Behältnis"
101
+ chapter.add_paragraph paragraph
102
+ picture = Text::Picture.new
103
+ flexmock(picture).should_receive(:path).and_return('/resources/oddb/logo.png')
104
+ flexmock(picture).should_receive(:filename).and_return('logo.png')
105
+ chapter.add_paragraph picture
106
+ document.add_chapter(chapter)
107
+ document
108
+ end
109
+ def test_patinfo
110
+ package = setup_package
111
+ package.patinfo.de = setup_patinfo
112
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
113
+ assert_equal "CH - ODDB.org | Medikamente | Gebrauchsinformation | Amantadin by Producer | Open Drug Database", get_title
114
+ assert is_text_present("1. Bezeichnung\nAmantadin Product")
115
+ end
116
+ def test_patinfo__limited
117
+ ODDB.config.query_limit = 1
118
+ package = setup_package
119
+ package.patinfo.de = setup_patinfo
120
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
121
+ assert_equal "CH - ODDB.org | Medikamente | Gebrauchsinformation | Amantadin by Producer | Open Drug Database", get_title
122
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
123
+ assert_equal 'CH - ODDB.org | Medikamente | Open Drug Database',
124
+ get_title
125
+ assert is_text_present("Abfragebeschränkung")
126
+ ensure
127
+ ODDB.config.query_limit = 20
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ # Selenium::TestProduct -- de.oddb.org -- 18.04.2008 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+
6
+ require 'selenium/unit'
7
+ require 'stub/model'
8
+ require 'oddb/drugs'
9
+ require 'oddb/util'
10
+
11
+ module ODDB
12
+ module Selenium
13
+ class TestAdminProduct < Test::Unit::TestCase
14
+ include Selenium::TestCase
15
+ def setup
16
+ Drugs::ActiveAgent.instances.clear
17
+ Drugs::Composition.instances.clear
18
+ Drugs::Sequence.instances.clear
19
+ Drugs::Product.instances.clear
20
+ Business::Company.instances.clear
21
+ super
22
+ end
23
+ def setup_product
24
+ product = Drugs::Product.new
25
+ product.name.de = "Product"
26
+ company = Business::Company.new
27
+ company.name.de = 'Producer AG'
28
+ product.company = company
29
+ company.save
30
+ product.save
31
+ product
32
+ end
33
+ def test_product
34
+ product = setup_product
35
+ user = login_admin
36
+ uid = product.uid
37
+ open "/de/drugs/product/uid/#{uid}"
38
+ assert_equal "CH - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
39
+ assert is_element_present("company")
40
+ assert is_text_present("Product")
41
+ assert_equal 'Producer AG', get_value('company')
42
+ end
43
+ def test_product__update__success
44
+ product = setup_product
45
+ user = login_admin
46
+ company = Business::Company.new
47
+ company.name.de = 'New Company'
48
+ company.save
49
+ uid = product.uid
50
+ open "/de/drugs/product/uid/#{uid}"
51
+ assert_equal "CH - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
52
+ type 'company', 'New Company'
53
+ click 'update'
54
+ wait_for_page_to_load 30
55
+
56
+ assert_equal "CH - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
57
+ assert_equal 'New Company', get_value('company')
58
+
59
+ assert_equal company, product.company
60
+ end
61
+ def test_product__update__error
62
+ product = setup_product
63
+ previous = product.company
64
+ user = login_admin
65
+ uid = product.uid
66
+ open "/de/drugs/product/uid/#{uid}"
67
+ assert_equal "CH - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
68
+ type 'company', 'New Company'
69
+ click 'update'
70
+ wait_for_page_to_load 30
71
+
72
+ assert is_text_present('Der Zulassungsinhaber "New Company" ist nicht bekannt.')
73
+ assert_equal "CH - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
74
+ assert_equal 'Producer AG', get_value('company')
75
+
76
+ assert_equal previous, product.company
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Selenium::TestInit -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
4
+
5
+
6
+ $: << File.expand_path('..', File.dirname(__FILE__))
7
+
8
+ require 'selenium/unit'
9
+ require 'stub/model'
10
+ require 'oddb/drugs'
11
+ require 'oddb/util'
12
+
13
+ module ODDB
14
+ module Selenium
15
+ class TestProducts < Test::Unit::TestCase
16
+ include Selenium::TestCase
17
+ def setup
18
+ Drugs::Product.instances.clear
19
+ super
20
+ end
21
+ def setup_product(name)
22
+ product = Drugs::Product.new
23
+ sequence = Drugs::Sequence.new
24
+ sequence.product = product
25
+ sequence.atc = Drugs::Atc.new('N04BB01')
26
+ company = Business::Company.new
27
+ company.name.de = 'Producer AG'
28
+ product.company = company
29
+ company.save
30
+ product.name.de = name
31
+ product.save
32
+ end
33
+ def test_products
34
+ ODDB.config.query_limit = 20
35
+ setup_product("Amantadin by Producer")
36
+ setup_product("Amantadin by someone Else")
37
+ setup_product("4N Pflaster")
38
+ @selenium.open "/"
39
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", @selenium.get_title
40
+ @selenium.click "link=Arzneimittel A-Z"
41
+ @selenium.wait_for_page_to_load 30
42
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
43
+ @selenium.get_title
44
+ assert @selenium.is_text_present("Bitte wählen Sie den anzuzeigenden Bereich")
45
+ assert @selenium.is_element_present("link=A")
46
+ assert @selenium.is_element_present("link=0-9")
47
+
48
+ @selenium.click "link=A"
49
+ @selenium.wait_for_page_to_load 30
50
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
51
+ @selenium.get_title
52
+ assert @selenium.is_text_present('Amantadin by Producer')
53
+ assert @selenium.is_text_present('Amantadin by someone Else')
54
+ assert !@selenium.is_text_present('4N Pflaster')
55
+ assert @selenium.is_text_present('Producer AG')
56
+ assert @selenium.is_text_present('N04BB01')
57
+
58
+ flexstub(@server['test:preset-session-id']).should_receive(:pagelength).and_return(1)
59
+
60
+ @selenium.refresh
61
+ @selenium.wait_for_page_to_load 30
62
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
63
+ @selenium.get_title
64
+ assert @selenium.is_text_present('Amantadin by Producer')
65
+ assert !@selenium.is_text_present('Amantadin by someone Else')
66
+ assert !@selenium.is_text_present('4N Pflaster')
67
+ assert @selenium.is_text_present('1 - 1')
68
+ assert @selenium.is_text_present('2 - 2')
69
+ assert !@selenium.is_text_present('3 - 2')
70
+
71
+ @selenium.click "link=2 - 2"
72
+ @selenium.wait_for_page_to_load 30
73
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
74
+ @selenium.get_title
75
+ assert !@selenium.is_text_present('Amantadin by Producer')
76
+ assert @selenium.is_text_present('Amantadin by someone Else')
77
+ assert !@selenium.is_text_present('4N Pflaster')
78
+ assert @selenium.is_text_present('1 - 1')
79
+ assert @selenium.is_text_present('2 - 2')
80
+ assert !@selenium.is_text_present('3 - 2')
81
+
82
+ @selenium.click "link=0-9"
83
+ @selenium.wait_for_page_to_load 30
84
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
85
+ @selenium.get_title
86
+ assert !@selenium.is_text_present('Amantadin by Producer')
87
+ assert !@selenium.is_text_present('Amantadin by someone Else')
88
+ assert @selenium.is_text_present('4N Pflaster')
89
+
90
+ @selenium.click "link=4N Pflaster"
91
+ @selenium.wait_for_page_to_load 30
92
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | 4N Pflaster | Markenname | Open Drug Database",
93
+ @selenium.get_title
94
+ end
95
+ def test_products__sort
96
+ setup_product("Amantadin by Producer")
97
+ setup_product("Amantadin by someone Else")
98
+ setup_product("4N Pflaster")
99
+ @selenium.open "/"
100
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", @selenium.get_title
101
+ @selenium.click "link=Arzneimittel A-Z"
102
+ @selenium.wait_for_page_to_load 30
103
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
104
+ @selenium.get_title
105
+ assert @selenium.is_text_present("Bitte wählen Sie den anzuzeigenden Bereich")
106
+ assert @selenium.is_element_present("link=A")
107
+ assert @selenium.is_element_present("link=0-9")
108
+
109
+ @selenium.click "link=A"
110
+ @selenium.wait_for_page_to_load 30
111
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
112
+ @selenium.get_title
113
+ assert @selenium.is_text_present('Amantadin by Producer')
114
+ assert @selenium.is_text_present('Amantadin by someone Else')
115
+
116
+ @selenium.click "link=ATC-Code"
117
+ @selenium.wait_for_page_to_load 30
118
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
119
+ @selenium.get_title
120
+ @selenium.click "link=Hersteller"
121
+ @selenium.wait_for_page_to_load 30
122
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
123
+ @selenium.get_title
124
+ end
125
+ def test_products__limited
126
+ ODDB.config.query_limit = 1
127
+ setup_product("Amantadin by Producer")
128
+ setup_product("Amantadin by someone Else")
129
+ setup_product("4N Pflaster")
130
+ open "/de/drugs/products"
131
+ assert_equal "CH - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
132
+ @selenium.get_title
133
+ open "/de/drugs/products"
134
+ assert_equal 'CH - ODDB.org | Medikamente | Open Drug Database',
135
+ get_title
136
+ assert is_text_present("Abfragebeschränkung")
137
+ ensure
138
+ ODDB.config.query_limit = 20
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,715 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Selenium::TestSearch -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
4
+
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require 'selenium/unit'
8
+ require 'odba/drbwrapper'
9
+ require 'odba'
10
+ require 'oddb/drugs'
11
+ require 'oddb/util'
12
+ require 'stub/model'
13
+
14
+ module ODDB
15
+ module Selenium
16
+ class TestSearch < Test::Unit::TestCase
17
+ include Selenium::TestCase
18
+ def setup
19
+ Drugs::Package.instances.clear
20
+ Drugs::Product.instances.clear
21
+ Business::Company.instances.clear
22
+ @cache = flexstub(ODBA.cache)
23
+ flexstub(Currency).should_receive(:rate)\
24
+ .with('EUR', 'CHF').and_return(1.5)
25
+ currency = flexmock('Currency')
26
+ @currency = DRb.start_service('druby://localhost:0', currency)
27
+ ODDB.config.currency_rates = @currency.uri
28
+ @old_limit = ODDB.config.query_limit
29
+ ODDB.config.query_limit = 2000
30
+ currency.should_receive(:rate).with('EUR', 'CHF').and_return(1.6)
31
+ super
32
+ end
33
+ def setup_autosession(yus)
34
+ session = flexmock('session')
35
+ yus.should_receive(:autosession).and_return { |domain, block|
36
+ assert_equal 'org.oddb.de', domain
37
+ block.call session
38
+ }
39
+ session
40
+ end
41
+ def setup_package(name="Amantadin by Producer", atccode='N04BB01')
42
+ product = Drugs::Product.new
43
+ company = Business::Company.new
44
+ company.name.de = 'Producer AG'
45
+ product.company = company
46
+ company.save
47
+ sequence = Drugs::Sequence.new
48
+ sequence.product = product
49
+ atc = Drugs::Atc.new(atccode)
50
+ atc.name.de = 'Amantadin'
51
+ ddd = Drugs::Ddd.new('O')
52
+ ddd.dose = Drugs::Dose.new(10, 'mg')
53
+ atc.add_ddd(ddd)
54
+ sequence.atc = atc
55
+ composition = Drugs::Composition.new
56
+ galform = Drugs::GalenicForm.new
57
+ galform.description.de = 'Tabletten'
58
+ composition.galenic_form = galform
59
+ grp = Drugs::GalenicGroup.new('Tabletten')
60
+ grp.administration = 'O'
61
+ galform.group = grp
62
+ sequence.add_composition(composition)
63
+ substance = Drugs::Substance.new
64
+ substance.name.de = 'Amantadin'
65
+ dose = Drugs::Dose.new(100, 'mg')
66
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
67
+ composition.add_active_agent(active_agent)
68
+ package = Drugs::Package.new
69
+ code = Util::Code.new(:cid, '12345', 'CH')
70
+ package.add_code(code)
71
+ code = Util::Code.new(:festbetragsstufe, 3, 'CH')
72
+ package.add_code(code)
73
+ code = Util::Code.new(:festbetragsgruppe, 4, 'CH')
74
+ package.add_code(code)
75
+ code = Util::Code.new(:zuzahlungsbefreit, true, 'CH')
76
+ package.add_code(code)
77
+ part = Drugs::Part.new
78
+ part.package = package
79
+ part.size = 5
80
+ part.composition = composition
81
+ unit = Drugs::Unit.new
82
+ unit.name.de = 'Ampullen'
83
+ part.unit = unit
84
+ part.quantity = Drugs::Dose.new(20, 'ml')
85
+ package.name.de = name
86
+ package.sequence = sequence
87
+ package.add_price(Business::Price.new(:public, 'CH', 6))
88
+ package.add_price(Business::Price.new(:festbetrag, 'CH', 10))
89
+ package.save
90
+ package
91
+ end
92
+ def setup_remote_package(name, uid='55555', price=12, ikscat='B')
93
+ rpackage = flexmock('Remote Package')
94
+ rpackage.should_receive(:barcode).and_return("7680#{uid}0012")
95
+ rpackage.should_receive(:name_base).and_return(name)
96
+ rpackage.should_receive(:price_public).and_return {
97
+ price
98
+ }
99
+ rpackage.should_receive(:price_exfactory).and_return { nil }
100
+ rpackage.should_receive(:ikscat).and_return(ikscat)
101
+ rpackage.should_receive(:sl_entry).and_return(true)
102
+ rpackage.should_receive(:comparable_size)\
103
+ .and_return(Drugs::Dose.new(100, 'ml'))
104
+ rpackage.should_receive(:__drbref).and_return(uid)
105
+ rcompany = flexmock('Remote Company')
106
+ rpackage.should_receive(:company).and_return(rcompany)
107
+ rcompany.should_receive(:name).and_return('Producer (Schweiz) AG')
108
+ ratc = flexmock('Remote Atc Class')
109
+ ratc.should_receive(:ddds).and_return []
110
+ rpackage.should_receive(:atc_class).and_return(ratc)
111
+ ratc.should_receive(:code).and_return('N04BB01')
112
+ ratc.should_receive(:parent_code).and_return('N04BB')
113
+ flexmock(Drugs::Atc).should_receive(:find_by_code)
114
+ ratc.should_receive(:name).and_return("Rem\366tadine")
115
+ #ratc.should_receive(:de).and_return('Amantadine')
116
+ ragent = flexmock('Remote ActiveAgent')
117
+ rpackage.should_receive(:active_agents).and_return([ragent])
118
+ rsubstance = flexmock('Remote Substance')
119
+ ragent.should_receive(:dose).and_return(Drugs::Dose.new(100, 'mg'))
120
+ ragent.should_receive(:substance).and_return(rsubstance)
121
+ rsubstance.should_receive(:de).and_return('Amantadinum')
122
+ rgalform = flexmock('Remote Galenic Form')
123
+ rpackage.should_receive(:galenic_forms).and_return([rgalform])
124
+ rgalform.should_receive(:de).and_return('Tropfen')
125
+ rgroup = flexmock('Remote Galenic Group')
126
+ rgroup.should_receive(:de).and_return('Unbekannt')
127
+ rgalform.should_receive(:galenic_group).and_return(rgroup)
128
+ rpart = flexmock('Remote Part')
129
+ rpart.should_receive(:comparable_size)\
130
+ .and_return(Drugs::Dose.new(4))
131
+ rpart.should_ignore_missing
132
+ rpackage.should_receive(:parts).and_return [rpart]
133
+ @cache.should_receive(:fetch).with(uid.to_i).and_return(rpackage)
134
+ rpackage.should_ignore_missing
135
+ rpackage
136
+ end
137
+ def teardown
138
+ super
139
+ ODDB.config.query_limit = @old_limit
140
+ ODDB.config.remote_databases = []
141
+ @currency.stop_service
142
+ end
143
+ def test_search
144
+ ODDB.config.query_limit = 20
145
+ package = setup_package
146
+ open "/"
147
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
148
+ type "query", "Amantadin"
149
+ click "//input[@type='submit']"
150
+ wait_for_page_to_load 30
151
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
152
+ get_title
153
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
154
+ assert is_text_present('Amantadin by Producer')
155
+ assert is_text_present('100 mg')
156
+ assert is_text_present('5 Ampullen à 20 ml')
157
+ assert is_text_present('6.00')
158
+ assert !is_text_present('-4.00')
159
+ assert is_text_present('3')
160
+ assert is_text_present('Ja')
161
+ assert is_text_present('N04BB01')
162
+ assert is_text_present('Producer AG')
163
+ assert is_text_present('FB')
164
+
165
+ ## State::Drugs::Result does not re-search if the query is the same
166
+ package2 = Drugs::Package.new
167
+ package2.sequence = package.sequence
168
+ package2.save
169
+ package2.add_price(Business::Price.new(:public, 'CH', 999999))
170
+ open('/de/drugs/search/query/Amantadin')
171
+ wait_for_page_to_load 30
172
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
173
+ get_title
174
+ assert is_text_present('Amantadin by Producer')
175
+ assert !is_text_present('999999.00')
176
+
177
+ ## Sort result
178
+ click "//a[@name='th_package_infos']"
179
+ wait_for_page_to_load 30
180
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
181
+ get_title
182
+
183
+ click "//a[@name='th_package_infos']"
184
+ wait_for_page_to_load 30
185
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
186
+ get_title
187
+
188
+ click "//a[@name='th_ddd_prices']"
189
+ wait_for_page_to_load 30
190
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
191
+ get_title
192
+
193
+ click "//a[@name='th_company']"
194
+ wait_for_page_to_load 30
195
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
196
+ get_title
197
+
198
+
199
+ ## an empty Result:
200
+ type "query", "Gabapentin"
201
+ select "dstype", "Inhaltsstoff"
202
+ wait_for_page_to_load 30
203
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Gabapentin | Inhaltsstoff | Open Drug Database",
204
+ get_title
205
+ expected = <<-EOS
206
+ Ihr Such-Stichwort hat zu keinem Suchergebnis geführt. Bitte überprüfen Sie die Schreibweise und versuchen Sie es noch einmal.
207
+ EOS
208
+ assert is_text_present(expected.chop)
209
+ end
210
+ def test_search__ajax
211
+ setup_package
212
+ open "/"
213
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
214
+ type "query", "Producer"
215
+ select 'dstype', 'Preisvergleich'
216
+ # no click necessary
217
+ # click "//input[@type='submit']"
218
+ wait_for_page_to_load 30
219
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Producer | Preisvergleich | Open Drug Database",
220
+ get_title
221
+ assert is_text_present('Amantadin by Producer')
222
+ mouse_over 'package_infos12345'
223
+ assert !60.times {
224
+ break if (is_element_present("//body/div[5]/table") rescue false)
225
+ sleep 1
226
+ }
227
+ assert is_text_present('Festbetragsgruppe')
228
+ assert is_text_present('Festbetragsstufe')
229
+ assert is_text_present('3: Arzneimittel mit therapeutisch vergleichbarer Wirkung, insbesondere Arzneimittelkombinationen')
230
+ assert is_text_present('Zuzahlungsbefreit')
231
+ assert is_text_present('Ja')
232
+ assert is_text_present('Rezeptpflichtig')
233
+ # if there is no information stored, we should not assume a No here:
234
+ assert !is_text_present('Nein')
235
+ mouse_over 'ddd_price_12345.0'
236
+ assert !60.times {
237
+ break if (is_element_present("//body/div[6]/table") rescue false)
238
+ sleep 1
239
+ }
240
+ assert is_text_present('Verabreichungsform')
241
+ assert is_text_present('Oral')
242
+ assert is_text_present('Anmerkung')
243
+ assert is_text_present('Tagesdosis')
244
+ assert is_text_present('10 mg')
245
+ assert is_text_present('Apothekenverkaufspreis')
246
+ assert is_text_present('6.00')
247
+ assert is_text_present('Stärke')
248
+ assert is_text_present('100 mg')
249
+ assert is_text_present('Packungsgrösse')
250
+ assert is_text_present('5 Ampullen à 20 ml')
251
+ assert is_text_present('Berechnung')
252
+ assert is_text_present('( 10 mg / 100 mg ) x ( 6.00 / 5 Ampullen à 20 ml ) = EUR 0.01 / Tag')
253
+ end
254
+ def test_search__company
255
+ setup_package
256
+ open "/"
257
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
258
+ type "query", "Producer"
259
+ select 'dstype', 'Zulassungsinhaber'
260
+ # no click necessary
261
+ # click "//input[@type='submit']"
262
+ wait_for_page_to_load 30
263
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Producer | Zulassungsinhaber | Open Drug Database",
264
+ get_title
265
+ assert is_text_present('Amantadin by Producer')
266
+ assert is_text_present('100 mg')
267
+ assert is_text_present('5 Ampullen à 20 ml')
268
+ assert is_text_present('6.00')
269
+ assert !is_text_present('-4.00')
270
+ assert is_text_present('3')
271
+ assert is_text_present('Ja')
272
+ assert is_text_present('N04BB01')
273
+ assert is_text_present('Producer AG')
274
+ end
275
+ def test_search__compare
276
+ setup_package
277
+ open "/"
278
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
279
+ type "query", "amantadin"
280
+ select 'dstype', 'Preisvergleich'
281
+ # no click necessary
282
+ # click "//input[@type='submit']"
283
+ wait_for_page_to_load 30
284
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | amantadin | Preisvergleich | Open Drug Database",
285
+ get_title
286
+ assert is_text_present('Amantadin by Producer')
287
+ assert is_text_present('100 mg')
288
+ assert is_text_present('5 Ampullen à 20 ml')
289
+ assert is_text_present('6.00')
290
+ assert !is_text_present('-4.00')
291
+ assert is_text_present('3')
292
+ assert is_text_present('Ja')
293
+ assert is_text_present('N04BB01')
294
+ assert is_text_present('Producer AG')
295
+ end
296
+ def test_search__details
297
+ package = setup_package
298
+ package.add_code(Util::Code.new(:cid, '12345', 'CH'))
299
+ open "/"
300
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
301
+ type "query", "Amantadin"
302
+ click "//input[@type='submit']"
303
+ wait_for_page_to_load 30
304
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
305
+ get_title
306
+ assert is_text_present('Amantadin by Producer')
307
+
308
+ ## click through to Details
309
+ click "link=Amantadin 100 mg"
310
+ wait_for_page_to_load 30
311
+ assert_equal "CH - ODDB.org | Medikamente | Details | Amantadin by Producer | Open Drug Database",
312
+ get_title
313
+
314
+ ## click back to Result
315
+ click "link=Suchresultat"
316
+ wait_for_page_to_load 30
317
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
318
+ get_title
319
+ end
320
+ def test_search__direct_sort
321
+ setup_package("Amonamon")
322
+ setup_package("Nomamonamon")
323
+ open "/de/drugs/search/query/Producer/dstype/compare/sortvalue/product"
324
+ wait_for_page_to_load 30
325
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Producer | Preisvergleich | Open Drug Database",
326
+ get_title
327
+
328
+ assert_match(/^Nomamonamon/, get_text("cid_N04BB01_0"))
329
+ assert_match(/^Amonamon/, get_text("cid_N04BB01_1"))
330
+ end
331
+ def test_search__feedback
332
+ package = setup_package
333
+ package.add_code(Util::Code.new(:cid, '12345', 'CH'))
334
+ open "/"
335
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
336
+ type "query", "Amantadin"
337
+ click "//input[@type='submit']"
338
+ wait_for_page_to_load 30
339
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
340
+ get_title
341
+ assert is_text_present('Amantadin by Producer')
342
+
343
+ ## click through to Feedback
344
+ assert is_element_present("link=FB")
345
+ click "//a[@name='feedback_short']"
346
+ wait_for_page_to_load 30
347
+ assert_equal "CH - ODDB.org | Medikamente | Feedback | Amantadin by Producer | Open Drug Database",
348
+ get_title
349
+
350
+ ## click back to Result
351
+ click "link=Suchresultat"
352
+ wait_for_page_to_load 30
353
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
354
+ get_title
355
+ end
356
+ def test_search__limited
357
+ ODDB.config.query_limit = 1
358
+ package = setup_package
359
+ open "/de/drugs/search/query/Amantadin"
360
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
361
+ get_title
362
+ open "/de/drugs/search/query/Amantadin"
363
+ assert_equal 'CH - ODDB.org | Medikamente | Open Drug Database',
364
+ get_title
365
+ assert is_text_present("Abfragebeschränkung")
366
+ ensure
367
+ ODDB.config.query_limit = 20
368
+ end
369
+ def test_search__admin_not_limited
370
+ ODDB.config.query_limit = 1
371
+ package = setup_package
372
+ user = login_admin
373
+ 2.times {
374
+ open "/de/drugs/search/query/Amantadin"
375
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
376
+ get_title
377
+ }
378
+ ensure
379
+ ODDB.config.query_limit = 20
380
+ end
381
+ def test_search__admin_atc
382
+ package = setup_package
383
+ package.sequence.atc = nil
384
+ user = login_admin
385
+ open "/de/drugs/search/query/Amantadin"
386
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
387
+ get_title
388
+ assert !is_text_present('Amantadin (N04BB01) - 1 Präparate')
389
+ assert is_element_present("atc-assign")
390
+ assert is_element_present("atc-assign-toggle")
391
+ assert is_element_present("atc-assign-form")
392
+ assert !is_visible("atc-assign")
393
+ click "link=ATC zuweisen"
394
+ assert is_visible("atc-assign")
395
+
396
+ type "atc-assign", "N04BB02"
397
+ submit "atc-assign-form"
398
+ wait_for_page_to_load 30
399
+
400
+ assert is_text_present('Der ATC-Code "N04BB02" ist nicht bekannt.')
401
+ assert !is_text_present('Amantadin (N04BB01) - 1 Präparate')
402
+ assert is_element_present("atc-assign")
403
+ assert is_element_present("atc-assign-toggle")
404
+ assert is_element_present("atc-assign-form")
405
+ assert is_visible("atc-assign")
406
+
407
+ type "atc-assign", "N04BB01"
408
+ submit "atc-assign-form"
409
+ wait_for_page_to_load 30
410
+
411
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
412
+ assert !is_element_present("atc-assign")
413
+ assert !is_element_present("atc-assign-toggle")
414
+ assert !is_element_present("atc-assign-form")
415
+ ensure
416
+ ODDB.config.query_limit = 20
417
+ end
418
+ def test_search__with_fachinfo
419
+ package = setup_package
420
+ package.fachinfo.de = "Fachinfo-Document"
421
+ open "/"
422
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
423
+ type "query", "Amantadin"
424
+ click "//input[@type='submit']"
425
+ wait_for_page_to_load 30
426
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
427
+ get_title
428
+ assert is_text_present('FI')
429
+ assert is_text_present('Amantadin by Producer')
430
+ assert is_text_present('100 mg')
431
+ assert is_text_present('5 Ampullen à 20 ml')
432
+ assert is_text_present('6.00')
433
+ assert !is_text_present('-4.00')
434
+ assert is_text_present('3')
435
+ assert is_text_present('Ja')
436
+ assert is_text_present('N04BB01')
437
+ assert is_text_present('Producer AG')
438
+ end
439
+ def test_search__multiple_substances
440
+ package = setup_package
441
+ substance = Drugs::Substance.new
442
+ substance.name.de = "Propranolol"
443
+ dose = Drugs::Dose.new(50, 'mg')
444
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
445
+ package.sequence.compositions.first.add_active_agent(active_agent)
446
+ open "/"
447
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
448
+ type "query", "Amantadin"
449
+ click "//input[@type='submit']"
450
+ wait_for_page_to_load 30
451
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
452
+ get_title
453
+ assert is_text_present('Amantadin by Producer')
454
+ assert is_text_present('2 Wirkstoffe')
455
+ end
456
+ def test_search__paged
457
+ pack = setup_package
458
+ other = setup_package('Amantadin Ophtal', 'S01AA01')
459
+ open "/"
460
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
461
+ flexstub(@server['test:preset-session-id']).should_receive(:pagelength).and_return(1)
462
+ type "query", "Amantadin"
463
+ click "//input[@type='submit']"
464
+ wait_for_page_to_load 30
465
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
466
+ get_title
467
+ assert is_text_present('Alle Präparate anzeigen')
468
+ assert !is_text_present('Zur ATC-Übersicht')
469
+ assert !is_text_present('<< 1 2 >>')
470
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
471
+ assert !is_text_present('Amantadin by Producer')
472
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
473
+ assert !is_text_present('Amantadin Ophtal')
474
+
475
+ click 'link=Alle Präparate anzeigen'
476
+ wait_for_page_to_load 30
477
+ assert !is_text_present('Alle Präparate anzeigen')
478
+ assert is_text_present('Zur ATC-Übersicht')
479
+ assert is_text_present('<< 1 2 >>')
480
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
481
+ assert is_text_present('Amantadin by Producer')
482
+ assert !is_text_present('Amantadin (S01AA01) - 1 Präparate')
483
+ assert !is_text_present('Amantadin Ophtal')
484
+
485
+ click 'link=>>'
486
+ wait_for_page_to_load 30
487
+ assert !is_text_present('Alle Präparate anzeigen')
488
+ assert is_text_present('Zur ATC-Übersicht')
489
+ assert is_text_present('<< 1 2 >>')
490
+ assert !is_text_present('Amantadin (N04BB01) - 1 Präparate')
491
+ assert !is_text_present('Amantadin by Producer')
492
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
493
+ assert is_text_present('Amantadin Ophtal')
494
+
495
+ click 'link=Zur ATC-Übersicht'
496
+ wait_for_page_to_load 30
497
+ assert is_text_present('Alle Präparate anzeigen')
498
+ assert !is_text_present('Zur ATC-Übersicht')
499
+ assert !is_text_present('<< 1 2 >>')
500
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
501
+ assert !is_text_present('Amantadin by Producer')
502
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
503
+ assert !is_text_present('Amantadin Ophtal')
504
+
505
+ click 'link=Amantadin (N04BB01) - 1 Präparate'
506
+ wait_for_page_to_load 30
507
+ assert is_text_present('Alle Präparate anzeigen')
508
+ assert !is_text_present('Zur ATC-Übersicht')
509
+ assert !is_text_present('<< 1 2 >>')
510
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
511
+ assert is_text_present('Amantadin by Producer')
512
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
513
+ assert !is_text_present('Amantadin Ophtal')
514
+
515
+ click 'link=Amantadin (S01AA01) - 1 Präparate'
516
+ wait_for_page_to_load 30
517
+ assert is_text_present('Alle Präparate anzeigen')
518
+ assert !is_text_present('Zur ATC-Übersicht')
519
+ assert !is_text_present('<< 1 2 >>')
520
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
521
+ assert !is_text_present('Amantadin by Producer')
522
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
523
+ assert is_text_present('Amantadin Ophtal')
524
+ end
525
+ def test_search__short
526
+ open "/"
527
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
528
+ type "query", "A"
529
+ click "//input[@type='submit']"
530
+ wait_for_page_to_load 30
531
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | A | Markenname | Open Drug Database",
532
+ get_title
533
+ expected = 'Ihr Such-Stichwort ergibt ein sehr grosses Resultat. Bitte verwenden Sie mindestens 3 Buchstaben.'
534
+ assert is_text_present(expected)
535
+ end
536
+ def test_search__substance
537
+ pack = setup_package
538
+ flexstub(pack).should_receive(:substance).and_return('Amantadin')
539
+ open "/"
540
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
541
+ type "query", "amantadin"
542
+ select 'dstype', 'Inhaltsstoff'
543
+ # no click necessary
544
+ # click "//input[@type='submit']"
545
+ wait_for_page_to_load 30
546
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | amantadin | Inhaltsstoff | Open Drug Database",
547
+ get_title
548
+ assert is_text_present('Amantadin by Producer')
549
+ assert is_text_present('100 mg')
550
+ assert is_text_present('5 Ampullen à 20 ml')
551
+ assert is_text_present('6.00')
552
+ assert !is_text_present('-4.00')
553
+ assert is_text_present('3')
554
+ assert is_text_present('Ja')
555
+ assert is_text_present('N04BB01')
556
+ assert is_text_present('Producer AG')
557
+ end
558
+ def test_search__export_csv
559
+ pack = setup_package
560
+ ODDB.config.query_limit = 20
561
+ package = setup_package
562
+ open "/"
563
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
564
+ type "query", "Amantadin"
565
+ click "//input[@type='submit']"
566
+ wait_for_page_to_load 30
567
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
568
+ get_title
569
+ assert is_element_present '//input[@name="export_csv"]'
570
+ click '//input[@name="export_csv"]'
571
+ wait_for_page_to_load 30
572
+ assert_equal "CH - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
573
+ get_title
574
+
575
+ assert is_text_present("CSV-Export Datenerfassung")
576
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
577
+
578
+ assert_equal "E-Mail", get_text("//label[@for='email']")
579
+ assert is_element_present("email")
580
+ assert_equal "Passwort", get_text("//label[@for='pass']")
581
+ assert is_element_present("pass")
582
+ assert_equal "Bestätigung", get_text("//label[@for='confirm_pass']")
583
+ assert is_element_present("confirm_pass")
584
+ assert_equal "Anrede", get_text("//label[@for='salutation']")
585
+ assert is_element_present("salutation")
586
+ assert_equal "Nachname", get_text("//label[@for='name_last']")
587
+ assert is_element_present("name_last")
588
+ assert_equal "Vorname", get_text("//label[@for='name_first']")
589
+ assert is_element_present("name_first")
590
+
591
+ assert is_text_present("2 x")
592
+ assert is_text_present("Amantadin_tradename.csv")
593
+
594
+ refresh
595
+ wait_for_page_to_load 30
596
+ assert_equal "CH - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
597
+ get_title
598
+
599
+ assert is_text_present("CSV-Export Datenerfassung")
600
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
601
+
602
+ assert_equal "E-Mail", get_text("//label[@for='email']")
603
+ assert is_element_present("email")
604
+ assert_equal "Passwort", get_text("//label[@for='pass']")
605
+ assert is_element_present("pass")
606
+ assert_equal "Bestätigung", get_text("//label[@for='confirm_pass']")
607
+ assert is_element_present("confirm_pass")
608
+ assert_equal "Anrede", get_text("//label[@for='salutation']")
609
+ assert is_element_present("salutation")
610
+ assert_equal "Nachname", get_text("//label[@for='name_last']")
611
+ assert is_element_present("name_last")
612
+ assert_equal "Vorname", get_text("//label[@for='name_first']")
613
+ assert is_element_present("name_first")
614
+
615
+ assert is_text_present("2 x")
616
+ assert is_text_present("Amantadin_tradename.csv")
617
+
618
+ end
619
+ def test_search__export_csv__step2_error
620
+ pack = setup_package
621
+ ODDB.config.query_limit = 20
622
+ package = setup_package
623
+ open "/"
624
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
625
+ type "query", "Amantadin"
626
+ click "//input[@type='submit']"
627
+ wait_for_page_to_load 30
628
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
629
+ get_title
630
+ assert is_element_present '//input[@name="export_csv"]'
631
+ click '//input[@name="export_csv"]'
632
+ wait_for_page_to_load 30
633
+ assert_equal "CH - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
634
+ get_title
635
+
636
+ assert is_text_present("CSV-Export Datenerfassung")
637
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
638
+
639
+ @auth.should_receive(:login).and_return { raise Yus::UnknownEntityError }
640
+ click "//input[@type='submit']"
641
+ wait_for_page_to_load 30
642
+ assert_equal "CH - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
643
+ get_title
644
+ assert is_text_present("Bitte füllen Sie alle Felder aus.")
645
+ %w{email pass confirm_pass salutation name_last name_first}.each { |key|
646
+ assert_equal "error", get_attribute("//label[@for='#{key}']@class")
647
+ }
648
+ end
649
+ def test_search__export_csv__step2
650
+ yus = flexmock("yus-server")
651
+ remote = DRb.start_service('druby://localhost:0', yus)
652
+ yus_session = setup_autosession(yus)
653
+ yus_session.should_receive(:get_entity_preferences).and_return({})
654
+ email = "downloader@oddb.org"
655
+ ODDB.config.auth_server = remote.uri
656
+
657
+ pack = setup_package
658
+ ODDB.config.query_limit = 20
659
+ package = setup_package
660
+ open "/"
661
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
662
+ type "query", "Amantadin"
663
+ click "//input[@type='submit']"
664
+ wait_for_page_to_load 30
665
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
666
+ get_title
667
+ assert is_element_present '//input[@name="export_csv"]'
668
+ click '//input[@name="export_csv"]'
669
+ wait_for_page_to_load 30
670
+ assert_equal "CH - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
671
+ get_title
672
+
673
+ assert is_text_present("CSV-Export Datenerfassung")
674
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
675
+
676
+ @auth.should_receive(:login).and_return { raise Yus::UnknownEntityError }
677
+ type "email", email
678
+ type "pass", "secret"
679
+ type "confirm_pass", "secret"
680
+ select "//select[@name='salutation']", "Herr"
681
+ type "name_last", "Test"
682
+ type "name_first", "Fritz"
683
+
684
+ yus_session.should_receive(:create_entity).with(email, "5ebe2294ecd0e0f08eab7690d2a6ee69")
685
+ user = mock_user email
686
+ ODDB.server = server = flexmock("server")
687
+ server.should_receive(:login).and_return(user)
688
+ @auth.should_receive(:login).and_return(user)
689
+
690
+ click "//input[@type='submit']"
691
+ wait_for_page_to_load 30
692
+
693
+ output = @http_server.redirected_output
694
+ assert_match /www.sandbox.paypal.com/, output
695
+ end
696
+ def test_search__export_csv__direct
697
+ pack = setup_package
698
+ user = login 'test.export@oddb.org', ['download', 'org.oddb.de.Amantadin_tradename.csv']
699
+ ODDB.config.query_limit = 20
700
+ package = setup_package
701
+ open "/"
702
+ assert_equal "CH - ODDB.org | Medikamente | Home | Open Drug Database", get_title
703
+ type "query", "Amantadin"
704
+ click "//input[@type='submit']"
705
+ wait_for_page_to_load 30
706
+ assert_equal "CH - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
707
+ get_title
708
+ assert is_element_present '//input[@name="export_csv"]'
709
+ click '//input[@name="export_csv"]'
710
+
711
+ assert @http_server.attachment
712
+ end
713
+ end
714
+ end
715
+ end