tests: basic carddav tests
This commit is contained in:
parent
de791511bf
commit
1194f07ed3
|
@ -10,7 +10,7 @@ start-up a vagrant box
|
|||
|
||||
install test requirements
|
||||
|
||||
pip install pytest caldav
|
||||
pip install pytest caldav pycarddav
|
||||
|
||||
run the tests
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from common import random_id
|
|||
|
||||
|
||||
def connect():
|
||||
url = "https://" + TEST_DOMAIN + "/cloud/remote.php/dav/calendars/me@mailinabox.lan/personal/"
|
||||
url = "https://" + TEST_DOMAIN + "/cloud/remote.php/dav/calendars/" + TEST_ADDRESS + "/personal/"
|
||||
client = caldav.DAVClient(url, username=TEST_ADDRESS, password=TEST_PASSWORD, ssl_verify_cert=False)
|
||||
principal = client.principal()
|
||||
calendars = principal.calendars()
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import pytest
|
||||
from pycarddav import carddav
|
||||
from time import sleep
|
||||
|
||||
from settings import *
|
||||
from common import random_id
|
||||
|
||||
|
||||
test_vcf = """
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
EMAIL;TYPE=PREF:foo@example.com
|
||||
N:John Doe;;;;
|
||||
FN:John Doe
|
||||
REV:2012-08-02T21:16:14+00:00
|
||||
PRODID:-//ownCloud//NONSGML Contacts 0.2//EN
|
||||
UID:c292c7212b
|
||||
END:VCARD
|
||||
"""
|
||||
|
||||
def connect():
|
||||
url = "https://" + TEST_DOMAIN + "/cloud/remote.php/carddav/addressbooks/" + TEST_ADDRESS + "/contacts/"
|
||||
return carddav.PyCardDAV(url, user=TEST_ADDRESS, passwd=TEST_PASSWORD, verify=False, write_support=True)
|
||||
|
||||
|
||||
def test_adddelete_contact():
|
||||
c = connect()
|
||||
abook = c.get_abook()
|
||||
prev_len = len(abook)
|
||||
|
||||
url, etag = c.upload_new_card(test_vcf)
|
||||
abook = c.get_abook()
|
||||
assert len(abook) == prev_len + 1
|
||||
|
||||
c.delete_vcard(url, etag)
|
||||
abook = c.get_abook()
|
||||
assert len(abook) == prev_len
|
||||
|
||||
|
||||
def test_update_contact():
|
||||
c = connect()
|
||||
url, etag = c.upload_new_card(test_vcf)
|
||||
|
||||
card = c.get_vcard(url)
|
||||
new_card = card.replace("John Doe", "Jane Doe")
|
||||
c.update_vcard(new_card, url, etag)
|
||||
|
||||
card = c.get_vcard(url)
|
||||
assert "John Doe" not in card
|
||||
assert "Jane Doe" in card
|
Loading…
Reference in New Issue