From cb849d44a68a914ca3cffefd42dac5a997424e45 Mon Sep 17 00:00:00 2001 From: skperez Date: Wed, 23 Aug 2023 21:04:59 -0700 Subject: [PATCH] Fixed bug introduced in issues/36 where valid bboxes were raising an exception --- subscriber/podaac_access.py | 5 +---- tests/test_subscriber.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/subscriber/podaac_access.py b/subscriber/podaac_access.py index 77ef65e..4ce3b24 100644 --- a/subscriber/podaac_access.py +++ b/subscriber/podaac_access.py @@ -188,10 +188,7 @@ def validate(args): raise ValueError( "Error parsing '--bounds': " + args.bbox + ". Format is W Longitude,S Latitude,E Longitude,N Latitude without spaces ") # noqa E501 - if num_bounds[0] > num_bounds[2]: - raise ValueError('Error parsing "--bounds": W Longitude must be <= E Longitude') - - if num_bounds[1] > num_bounds[2]: + if num_bounds[1] > num_bounds[3]: raise ValueError('Error parsing "--bounds": S Latitude must be <= N Latitude') diff --git a/tests/test_subscriber.py b/tests/test_subscriber.py index f40994c..59b2b97 100644 --- a/tests/test_subscriber.py +++ b/tests/test_subscriber.py @@ -164,6 +164,17 @@ def test_validate(): with pytest.raises(ValueError): a = validate(["-c", "viirs", "-d", "/data", "-b=-180,-90,180", "-m", "100"]) + # bbox crossing the IDL should not raise exception + validate(["-c", "viirs", "-d", "/data", "-dy", "-e", ".nc", "-m", "60", "-b=120,-60,-120,60"]) + # valid bbox values should not raise exception + validate(["-c", "viirs", "-d", "/data", "-dy", "-e", ".nc", "-m", "60", "-b=-180,-60,-120,60"]) + validate(["-c", "viirs", "-d", "/data", "-dy", "-e", ".nc", "-m", "60", "-b=-170,-20,-30,20"]) + + # bbox with invalid latitude values should raise an exception + with pytest.raises(ValueError): + validate(["-c", "viirs", "-d", "/data", "-b=-180,90,180,-90", "-m", "100"]) + + # #don't work # with pytest.raises(SystemExit): # a = validate([])