def test_query_text(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( caldavxml.PropertyFilter(caldavxml.TextMatch.fromString("1234", False), name="UID"), **{"name": ("VEVENT")} ) ], **{"name": "VCALENDAR", "test": "anyof"} ) ) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertTrue(isinstance(f.child.filters[0].filters[0], PropertyFilter)) self.assertTrue(isinstance(f.child.filters[0].filters[0].qualifier, TextMatch)) self.assertEqual(f.child.filters[0].filters[0].qualifier.text, "1234")
def test_timerange_query(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( *[caldavxml.TimeRange(**{"start": "20060605T160000Z", "end": "20060605T170000Z"})], **{"name": ("VEVENT", "VFREEBUSY", "VAVAILABILITY")} ) ], **{"name": "VCALENDAR"} ) ) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertTrue(isinstance(f.child.filters[0].qualifier, TimeRange)) self.assertTrue(isinstance(f.child.filters[0].qualifier.tzinfo, Timezone)) self.assertEqual(f.child.filters[0].qualifier.tzinfo.getTimezoneID(), "America/New_York")
def test_query_extended(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( *[caldavxml.TimeRange(**{"start": "20060605T160000Z"})], **{"name": ("VEVENT")} ), caldavxml.ComponentFilter(**{"name": ("VTODO")}), ], **{"name": "VCALENDAR", "test": "anyof"} ) ) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertEqual(len(f.child.filters), 2) self.assertTrue(isinstance(f.child.filters[0].qualifier, TimeRange))
def test_query_text(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( caldavxml.PropertyFilter( caldavxml.TextMatch.fromString("1234", False), name="UID", ), **{"name": ("VEVENT")}), ], **{ "name": "VCALENDAR", "test": "anyof" })) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertTrue( isinstance(f.child.filters[0].filters[0], PropertyFilter)) self.assertTrue( isinstance(f.child.filters[0].filters[0].qualifier, TextMatch)) self.assertEqual(f.child.filters[0].filters[0].qualifier.text, "1234")
def test_query_extended(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( *[ caldavxml.TimeRange(**{ "start": "20060605T160000Z", }) ], **{"name": ("VEVENT")}), caldavxml.ComponentFilter(**{"name": ("VTODO")}), ], **{ "name": "VCALENDAR", "test": "anyof" })) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertEqual(len(f.child.filters), 2) self.assertTrue(isinstance(f.child.filters[0].qualifier, TimeRange))
def test_timerange_query(self): """ Basic query test with time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( *[ caldavxml.TimeRange( **{ "start": "20060605T160000Z", "end": "20060605T170000Z" }) ], **{"name": ("VEVENT", "VFREEBUSY", "VAVAILABILITY")}) ], **{"name": "VCALENDAR"})) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter)) self.assertTrue(isinstance(f.child.filters[0].qualifier, TimeRange)) self.assertTrue( isinstance(f.child.filters[0].qualifier.tzinfo, Timezone)) self.assertEqual(f.child.filters[0].qualifier.tzinfo.getTimezoneID(), "America/New_York")
def test_query(self): """ Basic query test - no time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[caldavxml.ComponentFilter(**{"name": ("VEVENT", "VFREEBUSY", "VAVAILABILITY")})], **{"name": "VCALENDAR"} ) ) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter))
def test_query(self): """ Basic query test - no time range """ filter = caldavxml.Filter( caldavxml.ComponentFilter( *[ caldavxml.ComponentFilter( **{"name": ("VEVENT", "VFREEBUSY", "VAVAILABILITY")}) ], **{"name": "VCALENDAR"})) filter = Filter(filter) filter.child.settzinfo(Timezone(tzid="America/New_York")) j = filter.serialize() self.assertEqual(j["type"], "Filter") f = FilterBase.deserialize(j) self.assertTrue(isinstance(f, Filter))