def _create(self, name, id=None): """ Create a new calendar with display name `name` in `parent`. """ path = None if id is None: id = str(uuid.uuid1()) name = dav.DisplayName(name) cal = cdav.CalendarCollection() coll = dav.Collection() + cal type = dav.ResourceType() + coll prop = dav.Prop() + [type, name] set = dav.Set() + prop mkcol = dav.Mkcol() + set q = etree.tostring(mkcol.xmlelement(), encoding="utf-8", xml_declaration=True) path = url.join(self.parent.url.path, id) r = self.client.mkcol(path, q) if r.status == 201: # XXX Should we use self.canonical_url ? path = url.make(self.parent.url, path) else: raise error.MkcolError(r.raw) return (id, path)
def teardown(self): p = url.make(self.principal.url) path = url.join(p, testcal_id) cal = Calendar(self.caldav, name="Yep", parent = self.principal, url = path) cal.delete()
def create_calendar(client, parent, name, id=None): """ Create a new calendar with display name `name` in `parent`. """ path = None if id is None: id = str(uuid.uuid1()) name = dav.DisplayName(name) cal = cdav.CalendarCollection() coll = dav.Collection() + cal type = dav.ResourceType() + coll prop = dav.Prop() + [type, name] set = dav.Set() + prop mkcol = dav.Mkcol() + set q = etree.tostring(mkcol.xmlelement(), encoding="utf-8", xml_declaration=True) path = url.join(parent.url.path, id) r = client.mkcol(path, q) if r.status == 201: path = url.make(parent.url, path) else: raise error.MkcolError(r.raw) return (id, path)
def teardown(self): p = url.make(self.principal.url) path = url.join(p, testcal_id) cal = Calendar(self.caldav, name="Yep", parent=self.principal, url=path) cal.delete()
def _create(self, data, id=None, path=None): if id is None: id = str(uuid.uuid1()) if path is None: path = url.join(self.parent.url.path, id + ".ics") r = self.client.put(path, data, {"Content-Type": 'text/calendar; charset="utf-8"'}) if r.status == 204 or r.status == 201: # XXX Should we use self.canonical_url ? path = url.make(self.parent.url, path) else: raise error.PutError(r.raw) return (id, path)
def create_event(client, calendar, data, id=None): path = None if id is None: id = str(uuid.uuid1()) path = url.join(calendar.url.path, id + ".ics") r = client.put(path, data, {"Content-Type": "text/calendar; charset=\"utf-8\""}) if r.status == 204 or r.status == 201: path = url.make(calendar.url, path) else: raise error.PutError(r.raw) return (id, path)