Specifications:
Validate that a signal priority can be requested.
-
Given the site is connected
-
When we send a signal priority request
-
Then we should receive an acknowledgement
13 14 15 16 17 18 19 20 21 22 23 24 25 26
# File 'spec/site/tlc/signal_priority_spec.rb', line 13 Validator::Site.connected do |task,supervisor,site| signal_group = Validator.get_config('components','signal_group').keys.first command_list = build_command_list :M0022, :requestPriority, { requestId: SecureRandom.uuid()[0..3], signalGroupId: signal_group, type: 'new', level: 7, eta: 10, vehicleType: 'car' } prepare task, site send_command_and_confirm @task, command_list, "Request signal priority for signal group #{signal_group}" end
-
Validate that signal priority status can be requested.
-
Given the site is connected
-
When we request signal priority status
-
Then we should receive a status update
35 36 37 38
# File 'spec/site/tlc/signal_priority_spec.rb', line 35 Validator::Site.connected do |task,supervisor,site| request_status_and_confirm site, "signal group status", { S0033: [:status] } end
-
Validate that we can subscribe signal priority status
-
Given the site is connected
-
And we subscribe to signal priority status updates
-
Then we should receive an acknowledgement
-
And we should reive a status updates
48 49 50 51 52 53
# File 'spec/site/tlc/signal_priority_spec.rb', line 48 Validator::Site.connected do |task,supervisor,site| prepare task, site status_list = [{'sCI'=>'S0033','n'=>'status','uRt'=>'0'}] status_list.map! { |item| item.merge!('sOc' => true) } if use_sOc?(site) wait_for_status task, 'signal priority status', status_list end
-
Validate that a signal priority completes when we cancel it.
-
Given the site is connected
-
And we subscribe to signal priority status
-
When we send a signal priority request
-
Then the request state should become ‘received’
-
Then the request state should become ‘activated’
-
When we cancel the request
-
Then the state should become ‘completed’
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
# File 'spec/site/tlc/signal_priority_spec.rb', line 67 Validator::Site.connected do |task,supervisor,site| timeout = Validator.get_config('timeouts','priority_completion') component = Validator.get_config('main_component') signal_group_id = Validator.get_config('components','signal_group').keys.first prio = Validator::StatusHelpers::SignalPriorityRequestHelper.new( site, component: component, signal_group_id: signal_group_id, timeout: timeout, task: task ) prio.run do log "Before: Send unrelated signal priority request." prio. log "Send signal priority request, wait for reception." prio.request log "After: Send unrelated signal priority request." prio. prio.expect :received log "Signal priority request was received, wait for activation." prio.expect :activated log "Signal priority request was activated, now cancel it and wait for completion." prio.cancel prio.expect :completed log "Signal priority request was completed." end end
-
Validate that a signal priority times out if not cancelled.
-
Given the site is connected
-
And we subscribe to signal priority status
-
When we send a signal priority request
-
Then the request state should become ‘received’
-
Then the request state should become ‘activated’
-
When we do not cancel the request
-
Then the state should become ‘stale’
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
# File 'spec/site/tlc/signal_priority_spec.rb', line 114 Validator::Site.connected do |task,supervisor,site| timeout = Validator.get_config('timeouts','priority_completion') component = Validator.get_config('main_component') signal_group_id = Validator.get_config('components','signal_group').keys.first prio = Validator::StatusHelpers::SignalPriorityRequestHelper.new( site, component: component, signal_group_id: signal_group_id, timeout: timeout, task: task ) prio.run do log "Before: Send unrelated signal priority request." prio. log "Send signal priority request, wait for reception." prio.request log "After: Send unrelated signal priority request." prio. prio.expect :received log "Signal priority request was received, wait for activation." prio.expect :activated log "Signal priority request was activated, wait for it to become stale." # don't cancel request, it should then become stale by itself prio.expect :stale log "Signal priority request became stale." end end
-