caldav encoding test passing
This commit is contained in:
parent
e127ebeaa9
commit
352814aec9
2 changed files with 63 additions and 26 deletions
|
@ -391,11 +391,16 @@ impl<C: CalContext> QuickWritable<C> for Comp {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("comp");
|
let mut start = ctx.create_cal_element("comp");
|
||||||
start.push_attribute(("name", self.name.as_str()));
|
start.push_attribute(("name", self.name.as_str()));
|
||||||
|
match &self.additional_rules {
|
||||||
|
None => xml.write_event_async(Event::Empty(start)).await,
|
||||||
|
Some(rules) => {
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.write_event_async(Event::Start(start.clone())).await?;
|
||||||
self.prop_kind.write(xml, ctx.child()).await?;
|
rules.prop_kind.write(xml, ctx.child()).await?;
|
||||||
self.comp_kind.write(xml, ctx.child()).await?;
|
rules.comp_kind.write(xml, ctx.child()).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.write_event_async(Event::End(end)).await
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,6 +684,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::dav::types as dav;
|
use crate::dav::types as dav;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
use chrono::{Utc,TimeZone,DateTime};
|
||||||
|
|
||||||
async fn serialize<C: Context, Q: QuickWritable<C>>(ctx: C, elem: &Q) -> String {
|
async fn serialize<C: Context, Q: QuickWritable<C>>(ctx: C, elem: &Q) -> String {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
|
@ -718,6 +724,7 @@ mod tests {
|
||||||
mime: None,
|
mime: None,
|
||||||
comp: Some(Comp {
|
comp: Some(Comp {
|
||||||
name: Component::VCalendar,
|
name: Component::VCalendar,
|
||||||
|
additional_rules: Some(CompInner {
|
||||||
prop_kind: PropKind::Prop(vec![
|
prop_kind: PropKind::Prop(vec![
|
||||||
CalProp {
|
CalProp {
|
||||||
name: ComponentProperty("VERSION".into()),
|
name: ComponentProperty("VERSION".into()),
|
||||||
|
@ -727,25 +734,52 @@ mod tests {
|
||||||
comp_kind: CompKind::Comp(vec![
|
comp_kind: CompKind::Comp(vec![
|
||||||
Comp {
|
Comp {
|
||||||
name: Component::VEvent,
|
name: Component::VEvent,
|
||||||
comp_kind: CompKind::Comp(vec![]),
|
additional_rules: Some(CompInner {
|
||||||
prop_kind: PropKind::Prop(vec![
|
prop_kind: PropKind::Prop(vec![
|
||||||
CalProp { name: ComponentProperty("SUMMARY".into()), novalue: None },
|
CalProp { name: ComponentProperty("SUMMARY".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("UID".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("DTSTART".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("DTEND".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("DURATION".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("RRULE".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("RDATE".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("EXRULE".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("EXDATE".into()), novalue: None },
|
||||||
|
CalProp { name: ComponentProperty("RECURRENCE-ID".into()), novalue: None },
|
||||||
]),
|
]),
|
||||||
|
comp_kind: CompKind::Comp(vec![]),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
Comp {
|
Comp {
|
||||||
name: Component::VTimeZone,
|
name: Component::VTimeZone,
|
||||||
prop_kind: PropKind::Prop(vec![]),
|
additional_rules: None,
|
||||||
comp_kind: CompKind::Comp(vec![]),
|
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
|
}),
|
||||||
recurrence: None,
|
recurrence: None,
|
||||||
limit_freebusy_set: None,
|
limit_freebusy_set: None,
|
||||||
})),
|
})),
|
||||||
]))),
|
]))),
|
||||||
filter: Filter(CompFilter {
|
filter: Filter(CompFilter {
|
||||||
name: Component::VCalendar,
|
name: Component::VCalendar,
|
||||||
additional_rules: None,
|
additional_rules: Some(CompFilterRules::Matches(CompFilterMatch {
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![
|
||||||
|
CompFilter {
|
||||||
|
name: Component::VEvent,
|
||||||
|
additional_rules: Some(CompFilterRules::Matches(CompFilterMatch {
|
||||||
|
time_range: Some(TimeRange::FullRange(
|
||||||
|
Utc.with_ymd_and_hms(2006,1,4,0,0,0).unwrap(),
|
||||||
|
Utc.with_ymd_and_hms(2006,1,5,0,0,0).unwrap(),
|
||||||
|
)),
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})),
|
||||||
}),
|
}),
|
||||||
timezone: None,
|
timezone: None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,6 +839,9 @@ pub struct CalendarDataSupport {
|
||||||
/// "DAV:" namespace.
|
/// "DAV:" namespace.
|
||||||
pub struct Comp {
|
pub struct Comp {
|
||||||
pub name: Component,
|
pub name: Component,
|
||||||
|
pub additional_rules: Option<CompInner>,
|
||||||
|
}
|
||||||
|
pub struct CompInner {
|
||||||
pub prop_kind: PropKind,
|
pub prop_kind: PropKind,
|
||||||
pub comp_kind: CompKind,
|
pub comp_kind: CompKind,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue