mirror of
https://github.com/corazoncp/zoom-sched-poc.git
synced 2026-11-30 20:50:31 +00:00
fix(zoom): format create_meeting start_time with seconds (yyyy-MM-ddTHH:mm:ss)
- Normalize start_time_local in create_meeting to %Y-%m-%dT%H:%M:%S (converting aware datetimes to tz_name) so Zoom's Create Meeting API honors the requested time instead of falling back to now - Add test_pay_appointment_formats_start_time_with_seconds_for_zoom verifying outgoing Zoom payload - Verified with .venv/bin/pytest -v (85 passed)
This commit is contained in:
1 parent
6de8788d3d
commit
4b5936f617
2 files changed
+43
-1
No files matched your search
+16
-1
@@ -136,6 +136,21 @@ def create_meeting(
|
||||
duration_minutes: int = 60,
|
||||
) -> dict:
|
||||
"""Create a scheduled Zoom meeting on the account owner's calendar."""
|
||||
try:
|
||||
local_tz = ZoneInfo(tz_name)
|
||||
except ZoneInfoNotFoundError as exc:
|
||||
raise ZoomAPIError(400, f"Invalid timezone: {tz_name}") from exc
|
||||
|
||||
try:
|
||||
parsed = datetime.fromisoformat(start_time_local)
|
||||
except ValueError as exc:
|
||||
raise ZoomAPIError(400, "Invalid date/time format. Expected YYYY-MM-DDTHH:MM") from exc
|
||||
|
||||
# Zoom Create Meeting API requires seconds (yyyy-MM-ddTHH:mm:ss) when timezone is set;
|
||||
# HTML datetime-local omits seconds (YYYY-MM-DDTHH:MM), causing Zoom to default to now.
|
||||
local_dt = parsed.astimezone(local_tz) if parsed.tzinfo is not None else parsed
|
||||
formatted_start = local_dt.strftime("%Y-%m-%dT%H:%M:%S")
|
||||
|
||||
try:
|
||||
resp = requests.post(
|
||||
"https://api.zoom.us/v2/users/me/meetings",
|
||||
@@ -146,7 +161,7 @@ def create_meeting(
|
||||
json={
|
||||
"topic": topic,
|
||||
"type": 2,
|
||||
"start_time": start_time_local,
|
||||
"start_time": formatted_start,
|
||||
"duration": duration_minutes,
|
||||
"timezone": tz_name,
|
||||
"settings": {
|
||||
|
||||
@@ -697,6 +697,33 @@ def test_pay_appointment_forwards_duration_to_zoom(client, monkeypatch):
|
||||
assert captured_payloads[0]["duration"] == 45
|
||||
|
||||
|
||||
def test_pay_appointment_formats_start_time_with_seconds_for_zoom(client, monkeypatch):
|
||||
test_client, _ = client
|
||||
captured_payloads = []
|
||||
_mock_zoom_happy_path(monkeypatch, create_calls=captured_payloads)
|
||||
|
||||
c_resp = test_client.post(
|
||||
"/api/appointments",
|
||||
json={
|
||||
"credentials": SAMPLE_CREDS,
|
||||
"client_name": "Jorge Paez",
|
||||
"start_time_local": "2026-11-22T16:00",
|
||||
"timezone": "America/Bogota",
|
||||
},
|
||||
)
|
||||
assert c_resp.status_code == 201
|
||||
sid = c_resp.get_json()["session_id"]
|
||||
|
||||
p_resp = test_client.post(
|
||||
f"/api/appointments/{sid}/pay",
|
||||
json={"credentials": SAMPLE_CREDS},
|
||||
)
|
||||
assert p_resp.status_code == 200
|
||||
assert len(captured_payloads) == 1
|
||||
assert captured_payloads[0]["start_time"] == "2026-11-22T16:00:00"
|
||||
assert captured_payloads[0]["timezone"] == "America/Bogota"
|
||||
|
||||
|
||||
def test_concurrent_pay_creates_only_one_zoom_meeting(tmp_path: Path, monkeypatch):
|
||||
db_file = tmp_path / "concurrent_pay.db"
|
||||
app = create_app({"TESTING": True, "DB_PATH": str(db_file), "RATELIMIT_ENABLED": False})
|
||||
|
||||
Reference in new issue
Block a user