Decode stored calendar documents under Python 3
Debian Trixie package bundle / packages (push) Failing after 10m20s

This commit is contained in:
Mario Fetka
2026-07-23 16:41:27 +02:00
parent ad0de11e41
commit d56dd63bfd
2 changed files with 16 additions and 1 deletions
+2
View File
@@ -77,6 +77,8 @@ def open_store(user, store_cookie):
def json_to_ical(document):
from libbongo._calendar import bongojson, cal
if isinstance(document, bytes):
document = document.decode("utf-8", "strict")
value = bongojson.ParseString(document.strip())
if not value:
raise CalendarNotFound("invalid stored calendar object")
+14 -1
View File
@@ -20,11 +20,13 @@
# ****************************************************************************/
import unittest
from types import SimpleNamespace
from unittest import mock
from bongo_web.calendar_store import (CalendarNotFound, CalendarPathError,
PreconditionFailed, delete_event,
etag_matches, event_href, event_to_dict,
ical_to_json, make_event,
ical_to_json, json_to_ical, make_event,
list_calendar_events, list_calendars,
list_events, make_etag,
parse_calendar_path, write_event)
@@ -117,6 +119,17 @@ class CalendarPathTests(unittest.TestCase):
with self.subTest(data=data), self.assertRaises(ValueError):
ical_to_json(data)
def test_stored_json_bytes_are_accepted(self):
parsed = []
calendar_module = SimpleNamespace(
bongojson=SimpleNamespace(
ParseString=lambda value: parsed.append(value) or object()),
cal=SimpleNamespace(JsonToIcal=lambda value: "ICAL"))
with mock.patch.dict(
"sys.modules", {"libbongo._calendar": calendar_module}):
self.assertEqual(json_to_ical(b' {"event": "bytes"} '), b"ICAL")
self.assertEqual(parsed, ['{"event": "bytes"}'])
class CalendarMutationTests(unittest.TestCase):
def factory(self, store):