Skip to content

Commit

Permalink
factor our with_cycle_time_extended helper, guard against empty cycle…
Browse files Browse the repository at this point in the history
… time lists
  • Loading branch information
emiltin committed Jan 3, 2025
1 parent fa84a43 commit 3f23306
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
26 changes: 2 additions & 24 deletions spec/site/tlc/signal_plans_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,30 +260,8 @@
# 6. Then reading cycle time should confirm the reversion
specify 'cycle time is set with M0018', sxl: '>=1.0.13' do |example|
Validator::Site.connected do |task,supervisor,site|
extension = 5

# read current plan
plan = read_current_plan(site)

# read initial cycle times
times = read_cycle_times(site)
time = times[plan]

# change cycle tme
time_extended = time + extension
need_to_reset = true
set_cycle_time plan, time_extended, "Extend cycle time to #{time_extended} for plan #{plan}"

# read updated cycle times
increase = 5
times = read_cycle_times(site, "updated cycle times")
time_extended_actual = times[plan]
expect(time_extended_actual).to eq(time_extended)

ensure
if need_to_reset
log "Reset cycle time"
set_cycle_time plan, time
with_cycle_time_extended(site) do
log "Cycle time extension confirmed"
end
end
end
Expand Down
30 changes: 30 additions & 0 deletions spec/support/command_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,36 @@ def set_cycle_time plan, cycle_time, description="Set cycle time to #{cycle_time
send_command_and_confirm @task, command_list, description
end

def with_cycle_time_extended site, extension=5, &block
# read current plan
plan = read_current_plan(site)

# read initial cycle times
times = read_cycle_times(site)
time = times[plan]

expect(time).to_not be_nil, "Site returned empty cycle times list"

# change cycle tme
time_extended = time + extension
need_to_reset = true
set_cycle_time plan, time_extended, "Extend cycle time to #{time_extended} for plan #{plan}"

# read updated cycle times
increase = 5
times = read_cycle_times(site, "updated cycle times")
time_extended_actual = times[plan]
expect(time_extended_actual).to eq(time_extended)

block.yield
ensure
if need_to_reset
log "Reset cycle time"
set_cycle_time plan, time
end
end


def force_input input:, status:'True', value: 'True', validate:true
require_security_codes
if status == 'True'
Expand Down

0 comments on commit 3f23306

Please sign in to comment.