forked from mergeos-bounties/PlantGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_watering_schedule.py
More file actions
65 lines (51 loc) · 1.7 KB
/
Copy pathtest_watering_schedule.py
File metadata and controls
65 lines (51 loc) · 1.7 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from __future__ import annotations
from datetime import date
from typer.testing import CliRunner
from plantguide.care.cards import watering_schedule
from plantguide.cli import app
def test_schedule_returns_reproducible_check_dates() -> None:
result = watering_schedule(
"monstera_deliciosa",
18,
season="summer",
climate="temperate",
as_of=date(2026, 7, 17),
)
assert result["interval_days"] == 6
assert result["next_check_dates"] == ["2026-07-23", "2026-07-29", "2026-08-04"]
def test_larger_pot_and_humid_climate_extend_interval() -> None:
small_arid = watering_schedule(
"monstera_deliciosa", 10, climate="arid", as_of=date(2026, 7, 17)
)
large_humid = watering_schedule(
"monstera_deliciosa", 32, climate="humid", as_of=date(2026, 7, 17)
)
assert large_humid["interval_days"] > small_arid["interval_days"]
def test_schedule_rejects_unknown_climate() -> None:
try:
watering_schedule("monstera_deliciosa", 18, climate="tropical")
except ValueError as exc:
assert "climate must be one of" in str(exc)
else:
raise AssertionError("unknown climate should be rejected")
def test_schedule_cli_outputs_dates() -> None:
result = CliRunner().invoke(
app,
[
"care",
"schedule",
"--species",
"monstera_deliciosa",
"--pot-cm",
"18",
"--season",
"summer",
"--climate",
"temperate",
"--as-of",
"2026-07-17",
],
)
assert result.exit_code == 0
assert '"interval_days": 6' in result.stdout
assert "2026-07-23" in result.stdout