From cc888ebe9e15723b33506d1d9e694e76b84635e1 Mon Sep 17 00:00:00 2001 From: Unrud Date: Sat, 1 Jul 2017 00:11:07 +0200 Subject: [PATCH] Test adding contact to address book --- radicale/tests/static/contact1.vcf | 6 ++++++ radicale/tests/test_base.py | 32 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 radicale/tests/static/contact1.vcf diff --git a/radicale/tests/static/contact1.vcf b/radicale/tests/static/contact1.vcf new file mode 100644 index 0000000..3f526d2 --- /dev/null +++ b/radicale/tests/static/contact1.vcf @@ -0,0 +1,6 @@ +BEGIN:VCARD +VERSION:3.0 +UID:contact1 +N:Contact;;;; +FN:Contact +END:VCARD diff --git a/radicale/tests/test_base.py b/radicale/tests/test_base.py index b14967d..a20141f 100644 --- a/radicale/tests/test_base.py +++ b/radicale/tests/test_base.py @@ -92,6 +92,38 @@ class BaseRequestsMixIn: assert "Todo" in answer assert "UID:todo" in answer + def _create_addressbook(self, path): + return self.request( + "MKCOL", path, """\ + + + + + + + + + + +""") + + def test_add_contact(self): + """Add a contact.""" + status, _, _ = self._create_addressbook("/contacts.vcf/") + assert status == 201 + contact = get_file_content("contact1.vcf") + path = "/contacts.vcf/contact.vcf" + status, _, _ = self.request("PUT", path, contact) + assert status == 201 + status, headers, answer = self.request("GET", path) + assert status == 200 + assert "ETag" in headers.keys() + assert "VCARD" in answer + assert "UID:contact1" in answer + status, _, answer = self.request("GET", path) + assert status == 200 + assert "UID:contact1" in answer + def test_update(self): """Update an event.""" self.request("MKCOL", "/calendar.ics/")