forked from mergeos-bounties/PlantGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_care_filtering.py
More file actions
25 lines (17 loc) · 989 Bytes
/
Copy pathtest_care_filtering.py
File metadata and controls
25 lines (17 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pytest
from plantguide.care.filtering import filter_species_by_care
from plantguide.data.loader import load_species_catalog
def test_filter_species_by_light_and_water_uses_intersection() -> None:
species = [
{"id": "sun", "care": {"light": "Full sun", "water": "Water weekly"}},
{"id": "shade", "care": {"light": "Low light", "water": "Water weekly"}},
{"id": "dry", "care": {"light": "Full sun", "water": "Let soil dry"}},
]
matches = filter_species_by_care(species, light="sun", water="weekly")
assert [item["id"] for item in matches] == ["sun"]
def test_filter_species_by_care_matches_catalog_and_requires_a_filter() -> None:
matches = filter_species_by_care(load_species_catalog(), light="bright")
assert matches
assert all("bright" in str(item["care"].get("light") or "").lower() for item in matches)
with pytest.raises(ValueError, match="provide --light"):
filter_species_by_care(load_species_catalog())