taverna-player 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +18 -0
  3. data/LICENCE.rdoc +29 -0
  4. data/README.rdoc +663 -0
  5. data/Rakefile +65 -0
  6. data/app/assets/javascripts/taverna_player/application.js +14 -0
  7. data/app/assets/javascripts/taverna_player/runs.js +42 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/assets/stylesheets/taverna_player/application.css +13 -0
  10. data/app/assets/stylesheets/taverna_player/coderay.css +120 -0
  11. data/app/controllers/taverna_player/application_controller.rb +16 -0
  12. data/app/controllers/taverna_player/runs_controller.rb +18 -0
  13. data/app/controllers/taverna_player/service_credentials_controller.rb +18 -0
  14. data/app/helpers/taverna_player/application_helper.rb +55 -0
  15. data/app/helpers/taverna_player/runs_helper.rb +84 -0
  16. data/app/models/taverna_player/interaction.rb +25 -0
  17. data/app/models/taverna_player/run.rb +117 -0
  18. data/app/models/taverna_player/run_port.rb +148 -0
  19. data/app/models/taverna_player/service_credential.rb +56 -0
  20. data/app/views/layouts/taverna_player/embedded.html.erb +27 -0
  21. data/app/views/taverna_player/runs/_button.html.erb +19 -0
  22. data/app/views/taverna_player/runs/_info.html.erb +56 -0
  23. data/app/views/taverna_player/runs/_info.json.jbuilder +2 -0
  24. data/app/views/taverna_player/runs/_inputs.html.erb +34 -0
  25. data/app/views/taverna_player/runs/_inputs.json.jbuilder +8 -0
  26. data/app/views/taverna_player/runs/_interaction.html.erb +68 -0
  27. data/app/views/taverna_player/runs/_outputs.html.erb +41 -0
  28. data/app/views/taverna_player/runs/_poll.html.erb +27 -0
  29. data/app/views/taverna_player/runs/create.json.jbuilder +3 -0
  30. data/app/views/taverna_player/runs/embedded/_button.html.erb +19 -0
  31. data/app/views/taverna_player/runs/embedded/_info.html.erb +25 -0
  32. data/app/views/taverna_player/runs/embedded/_inputs.html.erb +32 -0
  33. data/app/views/taverna_player/runs/embedded/_outputs.html.erb +32 -0
  34. data/app/views/taverna_player/runs/embedded/new.html.erb +58 -0
  35. data/app/views/taverna_player/runs/embedded/show.html.erb +39 -0
  36. data/app/views/taverna_player/runs/embedded/show.js.erb +35 -0
  37. data/app/views/taverna_player/runs/index.html.erb +40 -0
  38. data/app/views/taverna_player/runs/index.json.jbuilder +1 -0
  39. data/app/views/taverna_player/runs/new.html.erb +56 -0
  40. data/app/views/taverna_player/runs/new.json.jbuilder +1 -0
  41. data/app/views/taverna_player/runs/show.html.erb +29 -0
  42. data/app/views/taverna_player/runs/show.js.erb +25 -0
  43. data/app/views/taverna_player/runs/show.json.jbuilder +25 -0
  44. data/app/views/taverna_player/service_credentials/_form.html.erb +53 -0
  45. data/app/views/taverna_player/service_credentials/edit.html.erb +18 -0
  46. data/app/views/taverna_player/service_credentials/index.html.erb +41 -0
  47. data/app/views/taverna_player/service_credentials/new.html.erb +17 -0
  48. data/app/views/taverna_player/service_credentials/show.html.erb +36 -0
  49. data/config/routes.rb +34 -0
  50. data/db/migrate/20130313105546_create_taverna_player_runs.rb +16 -0
  51. data/db/migrate/20130315163019_create_taverna_player_run_ports.rb +15 -0
  52. data/db/migrate/20130318170744_add_attachment_file_to_taverna_player_run_ports.rb +6 -0
  53. data/db/migrate/20130319183634_create_delayed_jobs.rb +22 -0
  54. data/db/migrate/20130320102600_add_status_message_to_taverna_player_runs.rb +5 -0
  55. data/db/migrate/20130321100110_add_depth_and_metadata_to_taverna_player_run_ports.rb +6 -0
  56. data/db/migrate/20130704095504_add_attachment_results_to_taverna_player_runs.rb +5 -0
  57. data/db/migrate/20130705142704_add_embedded_to_taverna_player_runs.rb +5 -0
  58. data/db/migrate/20130714140911_create_taverna_player_interactions.rb +13 -0
  59. data/db/migrate/20130717083653_add_proxy_to_taverna_player_runs.rb +6 -0
  60. data/db/migrate/20130717155415_add_stop_to_taverna_player_runs.rb +5 -0
  61. data/db/migrate/20130811152840_add_attachment_log_to_taverna_player_runs.rb +5 -0
  62. data/db/migrate/20130811211725_change_taverna_player_runs_state_column.rb +5 -0
  63. data/db/migrate/20130812155839_add_name_to_taverna_player_runs.rb +5 -0
  64. data/db/migrate/20130918135348_create_taverna_player_service_credentials.rb +15 -0
  65. data/db/migrate/20130919154200_add_displayed_to_taverna_player_interactions.rb +5 -0
  66. data/db/migrate/20131007153209_add_job_ref_to_taverna_player_runs.rb +13 -0
  67. data/db/migrate/20131010094537_add_reply_caching_to_taverna_player_interactions.rb +19 -0
  68. data/db/migrate/20131017141514_add_failure_message_to_taverna_player_run.rb +5 -0
  69. data/db/migrate/20131018152940_add_serial_number_to_taverna_player_interactions.rb +5 -0
  70. data/db/migrate/20131018160715_add_parent_run_id_to_taverna_player_runs.rb +5 -0
  71. data/db/migrate/20131102113933_add_page_uri_to_taverna_player_interaction.rb +5 -0
  72. data/db/migrate/20131105115218_remove_proxy_from_taverna_player_runs.rb +11 -0
  73. data/db/migrate/20131105141934_change_taverna_player_interactions_output_value_column_name.rb +5 -0
  74. data/db/migrate/20131112165520_add_user_to_taverna_player_run.rb +5 -0
  75. data/lib/generators/taverna_player/callbacks_generator.rb +25 -0
  76. data/lib/generators/taverna_player/controllers_generator.rb +30 -0
  77. data/lib/generators/taverna_player/install_generator.rb +30 -0
  78. data/lib/generators/taverna_player/job_generator.rb +26 -0
  79. data/lib/generators/taverna_player/models_generator.rb +27 -0
  80. data/lib/generators/taverna_player/renderers_generator.rb +26 -0
  81. data/lib/generators/taverna_player/views_generator.rb +27 -0
  82. data/lib/generators/templates/ReadMe.txt +118 -0
  83. data/lib/generators/templates/callbacks/render_callbacks.rb +56 -0
  84. data/lib/generators/templates/callbacks/worker_callbacks.rb +31 -0
  85. data/lib/generators/templates/controllers/runs_controller.rb +20 -0
  86. data/lib/generators/templates/controllers/service_credentials_controller.rb +20 -0
  87. data/lib/generators/templates/initializer.rb +154 -0
  88. data/lib/generators/templates/models/run.rb +20 -0
  89. data/lib/tasks/delete-cancelled-runs.rake +26 -0
  90. data/lib/tasks/delete-old-embedded-runs.rake +26 -0
  91. data/lib/taverna-player.rb +139 -0
  92. data/lib/taverna_player/concerns/controllers/runs_controller.rb +281 -0
  93. data/lib/taverna_player/concerns/controllers/service_credentials_controller.rb +89 -0
  94. data/lib/taverna_player/concerns/models/run.rb +205 -0
  95. data/lib/taverna_player/engine.rb +23 -0
  96. data/lib/taverna_player/model_proxy.rb +51 -0
  97. data/lib/taverna_player/output_renderer.rb +96 -0
  98. data/lib/taverna_player/render_callbacks.rb +41 -0
  99. data/lib/taverna_player/version.rb +15 -0
  100. data/lib/taverna_player/worker.rb +325 -0
  101. data/script/delayed_job +5 -0
  102. data/script/rails +8 -0
  103. data/taverna_player.gemspec +46 -0
  104. data/test/dummy/Rakefile +7 -0
  105. data/test/dummy/app/assets/javascripts/application.js +16 -0
  106. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  107. data/test/dummy/app/controllers/application_controller.rb +15 -0
  108. data/test/dummy/app/controllers/home_controller.rb +16 -0
  109. data/test/dummy/app/controllers/taverna_player/runs_controller.rb +25 -0
  110. data/test/dummy/app/controllers/taverna_player/service_credentials_controller.rb +25 -0
  111. data/test/dummy/app/controllers/workflows_controller.rb +17 -0
  112. data/test/dummy/app/models/user.rb +15 -0
  113. data/test/dummy/app/models/workflow.rb +32 -0
  114. data/test/dummy/app/views/home/index.html.erb +18 -0
  115. data/test/dummy/app/views/layouts/application.html.erb +43 -0
  116. data/test/dummy/app/views/workflows/index.html.erb +35 -0
  117. data/test/dummy/config.ru +4 -0
  118. data/test/dummy/config/application.rb +58 -0
  119. data/test/dummy/config/boot.rb +10 -0
  120. data/test/dummy/config/database.yml +25 -0
  121. data/test/dummy/config/environment.rb +5 -0
  122. data/test/dummy/config/environments/development.rb +37 -0
  123. data/test/dummy/config/environments/production.rb +67 -0
  124. data/test/dummy/config/environments/test.rb +37 -0
  125. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  126. data/test/dummy/config/initializers/inflections.rb +15 -0
  127. data/test/dummy/config/initializers/mime_types.rb +5 -0
  128. data/test/dummy/config/initializers/secret_token.rb +7 -0
  129. data/test/dummy/config/initializers/session_store.rb +8 -0
  130. data/test/dummy/config/initializers/taverna_player.example.rb +40 -0
  131. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  132. data/test/dummy/config/locales/en.yml +5 -0
  133. data/test/dummy/config/routes.rb +22 -0
  134. data/test/dummy/db/migrate/20130314103555_create_workflows.rb +12 -0
  135. data/test/dummy/db/migrate/20130318141557_create_taverna_player_runs.taverna_player.rb +17 -0
  136. data/test/dummy/db/migrate/20130318141558_create_taverna_player_run_ports.taverna_player.rb +16 -0
  137. data/test/dummy/db/migrate/20130318173013_add_attachment_file_to_taverna_player_run_ports.taverna_player.rb +7 -0
  138. data/test/dummy/db/migrate/20130319183816_create_delayed_jobs.taverna_player.rb +23 -0
  139. data/test/dummy/db/migrate/20130320102635_add_status_message_to_taverna_player_runs.taverna_player.rb +6 -0
  140. data/test/dummy/db/migrate/20130321161859_add_depth_and_metadata_to_taverna_player_run_ports.taverna_player.rb +7 -0
  141. data/test/dummy/db/migrate/20130704100146_add_attachment_results_to_taverna_player_runs.taverna_player.rb +6 -0
  142. data/test/dummy/db/migrate/20130705142816_add_embedded_to_taverna_player_runs.taverna_player.rb +6 -0
  143. data/test/dummy/db/migrate/20130714142144_create_taverna_player_interactions.taverna_player.rb +14 -0
  144. data/test/dummy/db/migrate/20130717084809_add_proxy_to_taverna_player_runs.taverna_player.rb +7 -0
  145. data/test/dummy/db/migrate/20130718102707_add_stop_to_taverna_player_runs.taverna_player.rb +6 -0
  146. data/test/dummy/db/migrate/20130811204449_add_attachment_log_to_taverna_player_runs.taverna_player.rb +6 -0
  147. data/test/dummy/db/migrate/20130811212709_change_taverna_player_runs_state_column.taverna_player.rb +6 -0
  148. data/test/dummy/db/migrate/20130812161152_add_name_to_taverna_player_runs.taverna_player.rb +6 -0
  149. data/test/dummy/db/migrate/20130918155525_create_taverna_player_service_credentials.taverna_player.rb +16 -0
  150. data/test/dummy/db/migrate/20130919155202_add_displayed_to_taverna_player_interactions.taverna_player.rb +6 -0
  151. data/test/dummy/db/migrate/20131007153659_add_job_ref_to_taverna_player_runs.taverna_player.rb +14 -0
  152. data/test/dummy/db/migrate/20131016123941_add_reply_caching_to_taverna_player_interactions.taverna_player.rb +20 -0
  153. data/test/dummy/db/migrate/20131017141614_add_failure_message_to_taverna_player_run.taverna_player.rb +6 -0
  154. data/test/dummy/db/migrate/20131018153316_add_serial_number_to_taverna_player_interactions.taverna_player.rb +6 -0
  155. data/test/dummy/db/migrate/20131018164614_add_parent_run_id_to_taverna_player_runs.taverna_player.rb +6 -0
  156. data/test/dummy/db/migrate/20131102114343_add_page_uri_to_taverna_player_interaction.taverna_player.rb +6 -0
  157. data/test/dummy/db/migrate/20131105115724_remove_proxy_from_taverna_player_runs.taverna_player.rb +12 -0
  158. data/test/dummy/db/migrate/20131105142417_change_taverna_player_interactions_output_value_column_name.taverna_player.rb +6 -0
  159. data/test/dummy/db/migrate/20131112165815_add_user_to_taverna_player_run.taverna_player.rb +6 -0
  160. data/test/dummy/db/migrate/20131114130937_create_users.rb +10 -0
  161. data/test/dummy/db/schema.rb +123 -0
  162. data/test/dummy/lib/callbacks.rb +35 -0
  163. data/test/dummy/log/.gitkeep +0 -0
  164. data/test/dummy/public/404.html +26 -0
  165. data/test/dummy/public/422.html +26 -0
  166. data/test/dummy/public/500.html +25 -0
  167. data/test/dummy/public/favicon.ico +0 -0
  168. data/test/dummy/script/delayed_job +5 -0
  169. data/test/dummy/script/rails +6 -0
  170. data/test/dummy/test/functional/home_controller_test.rb +28 -0
  171. data/test/dummy/test/functional/workflows_controller_test.rb +21 -0
  172. data/test/fixtures/files/crassostrea_gigas.csv +737 -0
  173. data/test/fixtures/taverna_player/interactions.yml +32 -0
  174. data/test/fixtures/taverna_player/run_ports.yml +54 -0
  175. data/test/fixtures/taverna_player/runs.yml +69 -0
  176. data/test/fixtures/taverna_player/service_credentials.yml +25 -0
  177. data/test/fixtures/users.yml +16 -0
  178. data/test/fixtures/workflows.yml +32 -0
  179. data/test/functional/taverna_player/runs_controller_test.rb +316 -0
  180. data/test/functional/taverna_player/service_credentials_controller_test.rb +99 -0
  181. data/test/taverna_player_test.rb +25 -0
  182. data/test/test_helper.rb +33 -0
  183. data/test/unit/helpers/taverna_player/application_helper_test.rb +70 -0
  184. data/test/unit/helpers/taverna_player/runs_helper_test.rb +45 -0
  185. data/test/unit/taverna_player/interaction_test.rb +47 -0
  186. data/test/unit/taverna_player/run_port_test.rb +309 -0
  187. data/test/unit/taverna_player/run_test.rb +196 -0
  188. data/test/unit/taverna_player/service_credential_test.rb +64 -0
  189. data/test/workflows/hello.t2flow +164 -0
  190. data/test/workflows/list_with_errors.t2flow +107 -0
  191. data/test/workflows/pass_through.t2flow +12 -0
  192. metadata +539 -0
@@ -0,0 +1,32 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ unique_id: b6d0dad1-ef0a-436a-bd16-62f3fe767801
15
+ serial: ask0
16
+ replied: false
17
+ displayed: false
18
+ run_id: 4
19
+
20
+ two:
21
+ unique_id: 602f98fc-f1b7-4fbd-9ee3-d4aa001492bb
22
+ serial: Nested_workflow:Interaction0
23
+ replied: true
24
+ displayed: true
25
+ run_id: 3
26
+
27
+ three:
28
+ unique_id: 101d727f-31cf-4601-8c3c-9d936b9e6c5e
29
+ serial: Nested_workflow:Interaction0
30
+ replied: false
31
+ displayed: true
32
+ run_id: 5
@@ -0,0 +1,54 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ id: 1
15
+ name: Message
16
+ value: Hello, World!
17
+ port_type: TavernaPlayer::RunPort::Output
18
+ run_id: 1
19
+ depth: 0
20
+ metadata: "---\n:size: 13\n:type: text/plain"
21
+
22
+ two:
23
+ id: 2
24
+ name: OUT
25
+ port_type: TavernaPlayer::RunPort::Output
26
+ run_id: 2
27
+ depth: 1
28
+ metadata: "---\n:size:\n- 7\n- 7\n- 974\n- 974\n- 7\n:type:\n- text/plain\n- text/plain\n- application/x-error\n- application/x-error\n- text/plain"
29
+
30
+ three:
31
+ id: 3
32
+ name: IN_Value
33
+ value: Rob
34
+ port_type: TavernaPlayer::RunPort::Input
35
+ run_id: 3
36
+ depth: 0
37
+
38
+ four:
39
+ id: 4
40
+ name: OUT
41
+ value: Rob
42
+ port_type: TavernaPlayer::RunPort::Output
43
+ run_id: 3
44
+ depth: 0
45
+ metadata: "---\n:size: 3\n:type: text/plain"
46
+
47
+ five:
48
+ id: 5
49
+ name: Long_N_unnecessary_Name_OUT
50
+ value: (http://example.com/path?query=1)
51
+ port_type: TavernaPlayer::RunPort::Output
52
+ run_id: 4
53
+ depth: 0
54
+ metadata: "---\n:size: 33\n:type: text/plain"
@@ -0,0 +1,69 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ id: 1
15
+ run_id: 9dcfbaf1-4c55-40f0-9853-baa7f8410879
16
+ name: Test run 1
17
+ saved_state: pending
18
+ create_time: 2013-03-13 10:55:46
19
+ start_time: 2013-03-13 10:56:00
20
+ finish_time: 2013-03-13 10:56:32
21
+ workflow_id: 1
22
+
23
+ two:
24
+ id: 2
25
+ run_id: 13246c77-ffa3-449f-9b18-0f085717f8eb
26
+ name: Test run 2
27
+ saved_state: running
28
+ create_time: 2013-03-13 10:55:46
29
+ start_time: 2013-03-13 10:55:55
30
+ finish_time: 2013-03-13 10:57:07
31
+ workflow_id: 2
32
+
33
+ three:
34
+ id: 3
35
+ run_id: f8250afc-09c1-4129-ab28-e889a284594f
36
+ name: Test run 3
37
+ saved_state: finished
38
+ create_time: 2013-03-13 10:55:46
39
+ start_time: 2013-03-13 10:55:48
40
+ finish_time: 2013-03-13 10:58:22
41
+ workflow_id: 3
42
+ embedded: true
43
+
44
+ four:
45
+ id: 4
46
+ run_id: f8250afc-09c1-4129-ab28-e889a284594f
47
+ name: Test run 4
48
+ saved_state: running
49
+ create_time: 2013-03-13 10:55:46
50
+ start_time: 2013-03-13 10:55:48
51
+ workflow_id: 1
52
+
53
+ five:
54
+ id: 5
55
+ run_id: f8250afc-09c1-4129-ab28-e889a284594f
56
+ name: Test run 5
57
+ saved_state: running
58
+ create_time: 2013-03-13 10:55:46
59
+ start_time: 2013-03-13 10:55:48
60
+ workflow_id: 1
61
+
62
+ six:
63
+ id: 6
64
+ run_id: f8250afc-09c1-4129-ab28-e889a284594f
65
+ name: Test run 6
66
+ saved_state: failed
67
+ create_time: 2013-03-13 10:55:46
68
+ start_time: 2013-03-13 10:55:48
69
+ workflow_id: 1
@@ -0,0 +1,25 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ uri: rserve://example.com:6311
15
+ name: My R Server
16
+ description: R Server
17
+ login: myname
18
+ password: insecure!
19
+
20
+ two:
21
+ uri: http://example.org/my_service
22
+ name: My Web Service
23
+ description: Web Service
24
+ login: aname
25
+ password: bad-password!
@@ -0,0 +1,16 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ id: 1
15
+ name: Rob
16
+ email: rob@example.com
@@ -0,0 +1,32 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ one:
14
+ id: 1
15
+ title: Hello, World!
16
+ author: Robert Haines
17
+ description: Say "Hello, World!"
18
+ file: test/workflows/hello.t2flow
19
+
20
+ two:
21
+ id: 2
22
+ title: List of Fail
23
+ author: Robert Haines
24
+ description: Produce a list littered with errors
25
+ file: test/workflows/list_with_errors.t2flow
26
+
27
+ three:
28
+ id: 3
29
+ title: Pass Through
30
+ author: Robert Haines
31
+ description: Pass the input straight through to the output
32
+ file: test/workflows/pass_through.t2flow
@@ -0,0 +1,316 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ require 'test_helper'
14
+
15
+ module TavernaPlayer
16
+ class RunsControllerTest < ActionController::TestCase
17
+ setup do
18
+ @run1 = taverna_player_runs(:one)
19
+ @run2 = taverna_player_runs(:two)
20
+ @run3 = taverna_player_runs(:three)
21
+ @run4 = taverna_player_runs(:four)
22
+ @run5 = taverna_player_runs(:five)
23
+ @int = taverna_player_interactions(:one)
24
+ @workflow = workflows(:one)
25
+ @routes = TavernaPlayer::Engine.routes
26
+ end
27
+
28
+ test "should route to runs" do
29
+ assert_routing "/runs",
30
+ { :controller => "taverna_player/runs", :action => "index" }, {}, {},
31
+ "Did not route correctly"
32
+ end
33
+
34
+ test "should route to a run" do
35
+ assert_routing "/runs/1",
36
+ { :controller => "taverna_player/runs", :action => "show",
37
+ :id => "1" }, {}, {}, "Did not route correctly"
38
+ end
39
+
40
+ test "should route to a run output" do
41
+ assert_routing "/runs/1/output/OUT",
42
+ { :controller => "taverna_player/runs", :action => "output",
43
+ :id => "1", :port => "OUT" }, {}, {}, "Did not route correctly"
44
+ end
45
+
46
+ test "should route to a deep run output" do
47
+ assert_routing "/runs/1/output/OUT/0/0",
48
+ { :controller => "taverna_player/runs", :action => "output",
49
+ :id => "1", :port => "OUT", :path => "0/0" }, {}, {},
50
+ "Did not route correctly"
51
+ end
52
+
53
+ test "should route to a run input" do
54
+ assert_routing "/runs/1/input/IN",
55
+ { :controller => "taverna_player/runs", :action => "input",
56
+ :id => "1", :port => "IN" }, {}, {}, "Did not route correctly"
57
+ end
58
+
59
+ test "should route to cancel on a run" do
60
+ assert_routing({ :method => "put", :path => "/runs/1/cancel" },
61
+ { :controller => "taverna_player/runs", :action => "cancel",
62
+ :id => "1" }, {}, {}, "Did not route correctly")
63
+ end
64
+
65
+ test "should route to interaction write proxy" do
66
+ assert_routing({ :method => "post",
67
+ :path => "/runs/1/interaction/#{@int.unique_id}" },
68
+ { :controller => "taverna_player/runs", :action => "write_interaction",
69
+ :id => "1", :int_id => @int.unique_id }, {}, {},
70
+ "Did not route correctly")
71
+ end
72
+
73
+ test "should route to interaction read proxy" do
74
+ assert_routing "/runs/1/interaction/#{@int.unique_id}",
75
+ { :controller => "taverna_player/runs", :action => "read_interaction",
76
+ :id => "1", :int_id => @int.unique_id, }, {}, {},
77
+ "Did not route correctly"
78
+ end
79
+
80
+ test "should route to results download" do
81
+ assert_routing "/runs/1/download/results",
82
+ { :controller => "taverna_player/runs", :action => "download_results",
83
+ :id => "1" }, {}, {}, "Did not route correctly"
84
+ end
85
+
86
+ test "should route to log download" do
87
+ assert_routing "/runs/1/download/log",
88
+ { :controller => "taverna_player/runs", :action => "download_log",
89
+ :id => "1" }, {}, {}, "Did not route correctly"
90
+ end
91
+
92
+ test "should route to output port download" do
93
+ assert_routing "/runs/1/download/output/Message",
94
+ { :controller => "taverna_player/runs", :action => "download_output",
95
+ :id => "1", :port => "Message" }, {}, {}, "Did not route correctly"
96
+ end
97
+
98
+ test "should get index and be overridden" do
99
+ get :index, :use_route => :taverna_player
100
+ assert_response :success, "Response was not success"
101
+ assert_not_nil assigns(:runs), "Did not assign a valid runs instance"
102
+ assert_not_nil assigns(:override)
103
+ assert_template "application", "Did not render with the correct layout"
104
+ end
105
+
106
+ test "should get new and not be overridden" do
107
+ get :new, :workflow_id => 1, :use_route => :taverna_player
108
+ assert_response :success, "Response was not success"
109
+ refute assigns(:override)
110
+ assert_template "application", "Did not render with the correct layout"
111
+ end
112
+
113
+ test "should get new embedded" do
114
+ get :new, :workflow_id => 1, :embedded => "true",
115
+ :use_route => :taverna_player
116
+ assert_response :success, "Response was not success"
117
+ assert_template "taverna_player/embedded",
118
+ "Did not render with the correct layout"
119
+ end
120
+
121
+ test "should show run with no interactions" do
122
+ get :show, :id => @run1, :use_route => :taverna_player
123
+ assert_response :success, "Response was not success"
124
+ refute assigns(:interaction), "No interactions for this run"
125
+ assert_template "application", "Did not render with the correct layout"
126
+ end
127
+
128
+ test "should show run with an undisplayed interaction" do
129
+ get :show, :id => @run4, :use_route => :taverna_player
130
+ assert_response :success, "Response was not success"
131
+ assert assigns(:interaction), "Should have an interaction for this run"
132
+ assert assigns(:new_interaction), "Should have new interaction flag"
133
+ assert_template "application", "Did not render with the correct layout"
134
+ end
135
+
136
+ test "should show run with a displayed interaction" do
137
+ get :show, :id => @run5, :use_route => :taverna_player
138
+ assert_response :success, "Response was not success"
139
+ assert assigns(:interaction), "Should have an interaction for this run"
140
+ refute assigns(:new_interaction), "Should not have new interaction flag"
141
+ assert_template "application", "Did not render with the correct layout"
142
+ end
143
+
144
+ test "should show run embedded ignoring replied interaction" do
145
+ get :show, :id => @run3, :use_route => :taverna_player
146
+ assert_response :success, "Response was not success"
147
+ refute assigns(:interaction), "Should not show replied interaction"
148
+ refute assigns(:new_interaction), "Should not have new interaction flag"
149
+ assert_template "taverna_player/embedded",
150
+ "Did not render with the correct layout"
151
+ end
152
+
153
+ test "should create run via browser" do
154
+ assert_difference("Run.count") do
155
+ post :create, :run => { :workflow_id => @workflow.id }
156
+ end
157
+
158
+ assert_redirected_to run_path(assigns(:run)),
159
+ "Did not redirect correctly"
160
+ assert_equal "Run was successfully created.", flash[:notice],
161
+ "Incorrect or missing flash notice"
162
+ assert assigns(:run).valid?, "Created run was invalid"
163
+ refute assigns(:run).user_id.nil?, "Run should have a user_id"
164
+ end
165
+
166
+ test "should create embedded run via browser" do
167
+ assert_difference("Run.count") do
168
+ post :create,
169
+ :run => { :workflow_id => @workflow.id, :embedded => "true" }
170
+ end
171
+
172
+ assert_redirected_to run_path(assigns(:run)),
173
+ "Did not redirect correctly"
174
+ assert_equal "Run was successfully created.", flash[:notice],
175
+ "Incorrect or missing flash notice"
176
+ assert assigns(:run).valid?, "Created run was invalid"
177
+ assert assigns(:run).embedded?, "Run not marked as embedded"
178
+ assert assigns(:run).user_id.nil?, "Run should not have a user_id"
179
+ end
180
+
181
+ test "should create run via json" do
182
+ assert_difference("Run.count") do
183
+ post :create, :run => { :workflow_id => @workflow.id },
184
+ :format => :json
185
+ end
186
+
187
+ assert_response :created, "Response was not created"
188
+ assert_equal "Run was successfully created.", flash[:notice],
189
+ "Incorrect or missing flash notice"
190
+ assert assigns(:run).valid?, "Created run was invalid"
191
+ refute assigns(:run).user_id.nil?, "Run should have a user_id"
192
+ end
193
+
194
+ test "should create embedded run via json" do
195
+ assert_difference("Run.count") do
196
+ post :create,
197
+ :run => { :workflow_id => @workflow.id, :embedded => "true" },
198
+ :format => :json
199
+ end
200
+
201
+ assert_response :created, "Response was not created"
202
+ assert_equal "Run was successfully created.", flash[:notice],
203
+ "Incorrect or missing flash notice"
204
+ assert assigns(:run).valid?, "Created run was invalid"
205
+ assert assigns(:run).embedded?, "Run not marked as embedded"
206
+ assert assigns(:run).user_id.nil?, "Run should not have a user_id"
207
+ end
208
+
209
+ test "should not destroy running run via browser" do
210
+ @request.env["HTTP_REFERER"] = "/runs"
211
+ assert_no_difference(["Run.count", "RunPort::Output.count"],
212
+ "Run count and output port count changed") do
213
+ delete :destroy, :id => @run1, :use_route => :taverna_player
214
+ end
215
+
216
+ assert_equal "Run must be cancelled before deletion.", flash[:error],
217
+ "Incorrect or missing flash notice"
218
+ assert_response :redirect, "Response was not a redirect"
219
+ assert_redirected_to runs_path, "Did not redirect correctly"
220
+ end
221
+
222
+ test "should not destroy running run via json" do
223
+ assert_no_difference(["Run.count", "RunPort::Output.count"],
224
+ "Run count and output port count changed") do
225
+ delete :destroy, :id => @run1, :format => :json
226
+ end
227
+
228
+ assert_equal "Run must be cancelled before deletion.", flash[:error],
229
+ "Incorrect or missing flash notice"
230
+ assert_response :forbidden, "Response was not forbidden"
231
+ end
232
+
233
+ test "should cancel run and redirect to index via browser" do
234
+ @request.env["HTTP_REFERER"] = "/runs"
235
+ put :cancel, :id => @run1, :use_route => :taverna_player
236
+
237
+ assert_response :redirect, "Response was not a redirect"
238
+ assert_redirected_to runs_path, "Did not redirect correctly"
239
+ end
240
+
241
+ test "should cancel run and redirect to show via browser" do
242
+ @request.env["HTTP_REFERER"] = "/runs/1"
243
+ put :cancel, :id => @run1, :use_route => :taverna_player
244
+
245
+ assert_response :redirect, "Response was not a redirect"
246
+ assert_redirected_to run_path(@run1), "Did not redirect correctly"
247
+ end
248
+
249
+ test "should cancel run via json" do
250
+ put :cancel, :id => @run1, :format => :json
251
+
252
+ assert_response :success, "Response was not success"
253
+ end
254
+
255
+ test "should destroy run and all associated ports and interactions" do
256
+ assert_difference(["Run.count", "RunPort::Input.count",
257
+ "RunPort::Output.count", "Interaction.count"], -1,
258
+ "Counts of objects did not reduce by 1") do
259
+ delete :destroy, :id => @run3, :use_route => :taverna_player
260
+ end
261
+
262
+ assert_response :redirect, "Response was not a redirect"
263
+ assert_redirected_to runs_path, "Did not redirect correctly"
264
+ end
265
+
266
+ test "should only return runs from workflow id 1" do
267
+ get :index, :workflow_id => @workflow
268
+ assert_response :success, "Response was not success"
269
+ assert_not_nil assigns(:runs), "Did not assign a valid runs instance"
270
+ assert_not_nil assigns(:override)
271
+ assert_not_equal Run.count, assigns(:runs).count, "Returned all runs"
272
+ assert_template "application", "Did not render with the correct layout"
273
+ end
274
+
275
+ test "should update run name via browser" do
276
+ put :update, :id => @run1, :run => { :name => "New name" }
277
+ assert_not_nil assigns(:run), "Did not assign a valid run instance"
278
+ assert_not_nil assigns(:update_parameters), "Did not filter params"
279
+ assert_equal "New name", assigns(:run).name, "Run name not updated"
280
+ assert_response :redirect, "Response was not a redirect"
281
+ assert_redirected_to run_path(assigns(:run)),
282
+ "Did not redirect correctly"
283
+ end
284
+
285
+ test "should only update run name via browser" do
286
+ put :update, :id => @run1,
287
+ :run => { :name => "New name", :run_id => "New id" }
288
+ assert_not_nil assigns(:run), "Did not assign a valid run instance"
289
+ assert_not_nil assigns(:update_parameters), "Did not filter params"
290
+ assert_equal "New name", assigns(:run).name, "Run name not updated"
291
+ assert_not_equal "New id", assigns(:run).run_id, "Run ID updated"
292
+ assert_response :redirect, "Response was not a redirect"
293
+ assert_redirected_to run_path(assigns(:run)),
294
+ "Did not redirect correctly"
295
+ end
296
+
297
+ test "should filter update parameters correctly" do
298
+ put :update, :id => @run1, :run => { :run_id => "New id" }
299
+ assert_not_nil assigns(:run), "Did not assign a valid run instance"
300
+ assert_nil assigns(:update_parameters), "Did not filter params"
301
+ assert_not_equal "New id", assigns(:run).run_id, "Run ID updated"
302
+ assert_response :redirect, "Response was not a redirect"
303
+ assert_redirected_to run_path(assigns(:run)),
304
+ "Did not redirect correctly"
305
+ end
306
+
307
+ test "should update run name via json" do
308
+ put :update, :id => @run1, :run => { :name => "New name" },
309
+ :format => :json
310
+ assert_not_nil assigns(:run), "Did not assign a valid run instance"
311
+ assert_not_nil assigns(:update_parameters), "Did not filter params"
312
+ assert_equal "New name", assigns(:run).name, "Run name not updated"
313
+ assert_response :success, "Response was not success"
314
+ end
315
+ end
316
+ end