def generate( self, record, forceKind=None, addProps=None, ): self._vCard = yield vCardFromRecord(record, forceKind, addProps, None) returnValue(self)
def test_forceKind(self): vcard_result = """BEGIN:VCARD VERSION:3.0 PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN UID:id1 FN:User 01 KIND:foobar N:01;User;;; END:VCARD """.replace("\n", "\r\n") record = yield self.directory.recordWithUID("id1") vcard = yield vCardFromRecord(record, forceKind="foobar") self.assertEqual(str(vcard), vcard_result)
def test_email(self): vcard_result = """BEGIN:VCARD VERSION:3.0 PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN UID:id2 EMAIL;TYPE=INTERNET,PREF,WORK:[email protected] FN:User 02 KIND:individual N:02;User;;; END:VCARD """.replace("\n", "\r\n") record = yield self.directory.recordWithUID("id2") vcard = yield vCardFromRecord(record) self.assertEqual(str(vcard), vcard_result)
def test_addProps(self): vcard_result = """BEGIN:VCARD VERSION:3.0 PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN UID:id1 FN:User 01 KEY:private KIND:individual N:01;User;;; END:VCARD """.replace("\n", "\r\n") record = yield self.directory.recordWithUID("id1") vcard = yield vCardFromRecord(record, addProps={"KEY": "private"}) self.assertEqual(str(vcard), vcard_result)
def test_adr(self): vcard_result = """BEGIN:VCARD VERSION:3.0 PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN UID:id4 ADR;LABEL="20300 Stevens Creek Blvd, Cupertino, CA 95014";TYPE=PARCEL,POST AL,PREF,WORK:;;20300 Stevens Creek Blvd\\, Cupertino\\, CA 95014;;;; FN:User 04 KIND:individual LABEL;TYPE=PARCEL,POSTAL:20300 Stevens Creek Blvd\\, Cupertino\\, CA 95014 N:04;User;;; END:VCARD """.replace("\n", "\r\n") record = yield self.directory.recordWithUID("id4") vcard = yield vCardFromRecord(record) self.assertEqual(str(vcard), vcard_result)
def test_parentURI(self): vcard_result = """BEGIN:VCARD VERSION:3.0 PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN UID:id1 FN:User 01 KIND:individual N:01;User;;; SOURCE:https://example.com:8443/contacts/id1.vcf END:VCARD """.replace("\n", "\r\n") self.patch(config, "EnableSSL", True) self.patch(config, "SSLPort", 8443) self.patch(config, "ServerHostName", "example.com") record = yield self.directory.recordWithUID("id1") vcard = yield vCardFromRecord(record, parentURI="/contacts") self.assertEqual(str(vcard), vcard_result)
def generate(self, record, forceKind=None, addProps=None,): self._vCard = yield vCardFromRecord(record, forceKind, addProps, None) returnValue(self)