-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(search): parse_facets now interprets quoted values correctly (#52)
- Loading branch information
Showing
2 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from esgpull.cli.utils import parse_facets | ||
from esgpull.models import Selection | ||
|
||
test_cases = [ | ||
(["ocean", "temperature"], Selection(query=["ocean", "temperature"])), | ||
(["ocean temperature"], Selection(query='"ocean temperature"')), | ||
( | ||
[ | ||
"project:CMIP6", | ||
"experiment_id:ssp126,ssp245,ssp585", | ||
"variable_id:hurt,lai,pr,sfcWind,tasmax,tasmin,ts,tos", | ||
"frequency:day", | ||
"nominal_resolution:100 km", | ||
], | ||
Selection( | ||
project="CMIP6", | ||
experiment_id=["ssp126", "ssp245", "ssp585"], | ||
variable_id=[ | ||
"hurt", | ||
"lai", | ||
"pr", | ||
"sfcWind", | ||
"tasmax", | ||
"tasmin", | ||
"ts", | ||
"tos", | ||
], | ||
frequency="day", | ||
nominal_resolution='"100 km"', | ||
), | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("facets, expected_query", test_cases) | ||
def test_parse_facets(facets, expected_query): | ||
result = parse_facets(facets) | ||
assert result == expected_query |