diff --git a/src/sorunlib/seq.py b/src/sorunlib/seq.py index 6fe880c..7d3b4d0 100644 --- a/src/sorunlib/seq.py +++ b/src/sorunlib/seq.py @@ -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) diff --git a/tests/test_seq.py b/tests/test_seq.py index 74dbaab..0a09015 100644 --- a/tests/test_seq.py +++ b/tests/test_seq.py @@ -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