Skip to content

Commit

Permalink
Skip scan if has already passed
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Oct 18, 2024
1 parent 9d591b5 commit 1f0babb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sorunlib/seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def scan(description, stop_time, width, az_drift=0, tag=None, subtype=None,
now = dt.datetime.now(dt.timezone.utc)
scan_stop = _timestamp_to_utc_datetime(stop_time)

# Check stop time has not already passed
if now > scan_stop:
return

# Check there is enough time to perform scan
if min_duration is not None:
start_by_time = scan_stop - dt.timedelta(seconds=min_duration)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def test_scan(patch_clients):
seq.scan(description='test', stop_time=target.isoformat(), width=20.)


@patch('sorunlib._internal.time.sleep', MagicMock())
def test_scan_passed_stop_time(patch_clients):
# This affects test runtime duration keep it short
target = dt.datetime.now(dt.timezone.utc) - dt.timedelta(seconds=10)
seq.scan(description='test', stop_time=target.isoformat(), width=20.)
seq.run.CLIENTS['acu'].generate_scan.start.assert_not_called()


@patch('sorunlib._internal.time.sleep', MagicMock())
def test_scan_passed_min_duration(patch_clients):
# This affects test runtime duration keep it short
Expand Down

0 comments on commit 1f0babb

Please sign in to comment.