16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
17 | 17 |
# MA 02110-1301, USA.
|
18 | 18 |
|
|
19 |
import unittest
|
|
20 |
|
19 | 21 |
from wsgiref.util import setup_testing_defaults
|
20 | 22 |
|
21 | |
from xandikos import caldav
|
|
23 |
from xandikos import caldav, davcommon
|
22 | 24 |
from xandikos.webdav import Property, WebDAVApp, ET
|
23 | 25 |
|
24 | 26 |
from xandikos.tests import test_webdav
|
|
69 | 71 |
code, headers, contents = self.mkcalendar(app, '/resource/bla')
|
70 | 72 |
self.assertEqual('201 Created', code)
|
71 | 73 |
self.assertEqual(b'', contents)
|
|
74 |
|
|
75 |
|
|
76 |
class ApplyTextMatchTest(unittest.TestCase):
|
|
77 |
|
|
78 |
def test_default_collation(self):
|
|
79 |
el = ET.Element('someel')
|
|
80 |
el.text = b"foobar"
|
|
81 |
self.assertTrue(caldav.apply_text_match(el, b"FOOBAR"))
|
|
82 |
self.assertTrue(caldav.apply_text_match(el, b"foobar"))
|
|
83 |
self.assertFalse(caldav.apply_text_match(el, b"fobar"))
|
|
84 |
|
|
85 |
def test_casecmp_collation(self):
|
|
86 |
el = ET.Element('someel')
|
|
87 |
el.set('collation', 'i;ascii-casemap')
|
|
88 |
el.text = b"foobar"
|
|
89 |
self.assertTrue(caldav.apply_text_match(el, b"FOOBAR"))
|
|
90 |
self.assertTrue(caldav.apply_text_match(el, b"foobar"))
|
|
91 |
self.assertFalse(caldav.apply_text_match(el, b"fobar"))
|
|
92 |
|
|
93 |
def test_cmp_collation(self):
|
|
94 |
el = ET.Element('someel')
|
|
95 |
el.text = b"foobar"
|
|
96 |
el.set('collation', 'i;octet')
|
|
97 |
self.assertFalse(caldav.apply_text_match(el, b"FOOBAR"))
|
|
98 |
self.assertTrue(caldav.apply_text_match(el, b"foobar"))
|
|
99 |
self.assertFalse(caldav.apply_text_match(el, b"fobar"))
|
|
100 |
|
|
101 |
def test_unknown_collation(self):
|
|
102 |
el = ET.Element('someel')
|
|
103 |
el.set('collation', 'i;blah')
|
|
104 |
el.text = b"foobar"
|
|
105 |
self.assertRaises(davcommon.UnknownCollation,
|
|
106 |
caldav.apply_text_match, el, b"FOOBAR")
|