3 class ContainerRequestsControllerTest < ActionController::TestCase
4 test "visit completed container request log tab" do
7 cr = api_fixture('container_requests')['completed']
8 container_uuid = cr['container_uuid']
9 container = Container.find(container_uuid)
11 get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
12 assert_response :success
14 assert_select "a", {:href=>"/collections/#{container['log']}", :text=>"Download the log"}
15 assert_select "a", {:href=>"#{container['log']}/baz"}
16 assert_not_includes @response.body, '<div id="event_log_div"'
19 test "visit running container request log tab" do
22 cr = api_fixture('container_requests')['running']
23 container_uuid = cr['container_uuid']
24 container = Container.find(container_uuid)
26 get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
27 assert_response :success
29 assert_includes @response.body, '<div id="event_log_div"'
30 assert_select 'Download the log', false
33 test "completed container request offers re-run option" do
36 uuid = api_fixture('container_requests')['completed']['uuid']
38 get :show, {id: uuid}, session_for(:active)
39 assert_response :success
41 assert_includes @response.body, "action=\"/container_requests/#{uuid}/copy\""
45 ['completed', false, false],
46 ['completed', true, false],
47 ['completed-older', false, true],
48 ['completed-older', true, true],
49 ].each do |cr_fixture, reuse_enabled, uses_acr|
50 test "container request #{uses_acr ? '' : 'not'} using arvados-cwl-runner copy #{reuse_enabled ? 'with' : 'without'} reuse enabled" do
51 completed_cr = api_fixture('container_requests')[cr_fixture]
52 # Set up post request params
53 copy_params = {id: completed_cr['uuid']}
55 copy_params.merge!({use_existing: true})
57 post(:copy, copy_params, session_for(:active))
59 copied_cr = assigns(:object)
60 assert_not_nil copied_cr
61 assert_equal 'Uncommitted', copied_cr[:state]
62 assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
63 assert_equal completed_cr['cmd'], copied_cr['cmd']
64 assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
66 assert copied_cr[:use_existing]
68 refute copied_cr[:use_existing]
70 # If the CR's command is arvados-cwl-runner, the appropriate flag should
74 # arvados-cwl-runner's default behavior is to enable reuse
75 assert_includes copied_cr['command'], 'arvados-cwl-runner'
76 assert_not_includes copied_cr['command'], '--disable-reuse'
78 assert_includes copied_cr['command'], 'arvados-cwl-runner'
79 assert_includes copied_cr['command'], '--disable-reuse'
80 assert_not_includes copied_cr['command'], '--enable-reuse'
83 # If no arvados-cwl-runner is being used, the command should be left alone
84 assert_equal completed_cr['command'], copied_cr['command']
93 ['uncommitted', false],
94 ].each do |cr_fixture, should_show|
95 test "provenance tab should #{should_show ? '' : 'not'} be shown on #{cr_fixture} container requests" do
96 cr = api_fixture('container_requests')[cr_fixture]
100 session_for(:active))
101 assert_response :success
103 assert_includes @response.body, "href=\"#Provenance\""
105 assert_not_includes @response.body, "href=\"#Provenance\""
110 test "container request display" do
113 cr = api_fixture('container_requests')['completed_with_input_mounts']
115 get :show, {id: cr['uuid']}, session_for(:active)
116 assert_response :success
118 assert_match /hello/, @response.body
119 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/foo" # mount input1
120 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/bar" # mount input2
121 assert_includes @response.body, "href=\"\/collections/1fd08fc162a5c6413070a8bd0bffc818+150" # mount workflow
122 assert_includes @response.body, "href=\"#Log\""
123 assert_includes @response.body, "href=\"#Provenance\""