New version number: 0.3
[bbdb-vcard.git] / test-bbdb-vcard.el
blob9f13764ba7c101362af3caef2b8e5f04c03845a3
1 ;;; Tests for bbdb-vcard.el
2 ;;
3 ;; Before proceeding, you should probably save your production bbdb file.
4 ;;
5 ;; To run the tests, eval this file.
6 ;; In case of failure, find test results in buffer `bbdb-vcard-test-result'.
7 ;;
8 ;; For the sake of minimality, not all test cases are rfc compliant.
11 (require 'bbdb-vcard)
13 (defun bbdb-vcard-import-test
14 (vcard bbdb-entry search-name
15 &optional search-company search-net check-creation-date-p)
16 "Import VCARD and search for it in bbdb by SEARCH-NAME,
17 SEARCH-COMPANY, (perhaps later) SEARCH-NET. If search result
18 disagrees with BBDB-ENTRY, talk about it in buffer
19 bbdb-vcard-test-result. timestamp and, if CHECK-CREATION-DATE-P is
20 nil, creation-date are not taken into account."
21 (bbdb-vcard-iterate-vcards 'bbdb-vcard-import-vcard vcard)
22 (let* ((search-company (or search-company ""))
23 (bbdb-search-result
24 (car (bbdb-search (bbdb-search (bbdb-records) search-name)
25 nil search-company))))
26 (setf (cdr (assoc 'timestamp (elt bbdb-search-result 7))) "2010-03-04"
27 (cdr (assoc 'timestamp (elt bbdb-entry 7))) "2010-03-04")
28 (unless check-creation-date-p
29 (setf (cdr (assoc 'creation-date (elt bbdb-search-result 7))) "2010-03-04"
30 (cdr (assoc 'creation-date (elt bbdb-entry 7))) "2010-03-04"))
31 (unless (equal (subseq bbdb-search-result 0 8)
32 (subseq bbdb-entry 0 8))
33 (princ "\nTest failed:\n" (get-buffer-create "bbdb-vcard-test-result"))
34 (prin1 vcard (get-buffer-create "bbdb-vcard-test-result"))
35 (princ "\nwas stored as\n" (get-buffer-create "bbdb-vcard-test-result"))
36 (prin1 (subseq bbdb-search-result 0 8)
37 (get-buffer-create "bbdb-vcard-test-result"))
38 (princ "\nbut was expected as\n" (get-buffer-create "bbdb-vcard-test-result"))
39 (prin1 bbdb-entry (get-buffer-create "bbdb-vcard-test-result")))))
41 (defun bbdb-vcard-normalize-notes (notes)
42 "Sort a BBDB NOTES field and delete the timestamps in order to make them
43 comparable after re-import."
44 (let ((notes (remove-alist 'notes 'timestamp)))
45 (setq notes (remove-alist 'notes 'creation-date))
46 (sort
47 notes
48 '(lambda (x y) (if (string= (symbol-name (car x)) (symbol-name (car y)))
49 (string< (cdr x) (cdr y))
50 (string< (symbol-name (car x)) (symbol-name (car y))))))))
52 (defun bbdb-vcard-normalize-record (record)
53 "Make BBDB RECORD comparable by deleting certain things and sorting others."
54 (setf (elt record 6) (bbdb-vcard-normalize-notes (elt record 7)))
55 (subseq record 0 7))
57 (defun bbdb-vcard-compare-bbdbs (first-bbdb second-bbdb)
58 "Compare two BBDB record lists. Tell about mismatches in buffer
59 `bbdb-vcard-test-result'."
60 (let ((i 0)
61 first-record second-record)
62 (while (or (nth i first-bbdb) (nth i second-bbdb))
63 (unless (equal (bbdb-vcard-normalize-record (nth i first-bbdb))
64 (bbdb-vcard-normalize-record (nth i second-bbdb)))
65 (princ "\nRe-import: comparison of these records failed:"
66 (get-buffer-create "bbdb-vcard-test-result"))
67 (print (bbdb-vcard-normalize-record (nth i first-bbdb))
68 (get-buffer-create "bbdb-vcard-test-result"))
69 (prin1 (bbdb-vcard-normalize-record (nth i second-bbdb))
70 (get-buffer-create "bbdb-vcard-test-result")))
71 (incf i))))
74 ;;; Try not to mess up our real BBDB:
75 (when bbdb-buffer
76 (save-buffer bbdb-buffer)
77 (kill-buffer bbdb-buffer))
78 (when (get-buffer "test-bbdb") (kill-buffer "test-bbdb"))
79 (setq bbdb-file "/tmp/test-bbdb")
80 (when (file-exists-p bbdb-file) (delete-file bbdb-file))
81 (when (get-buffer "bbdb-vcard-test-result") (kill-buffer "bbdb-vcard-test-result"))
84 ;;;; The Import Tests
85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
87 (bbdb-vcard-import-test
89 ** A vcard without any type parameters.
90 ------------------------------------------------------------
91 BEGIN:VCARD
92 VERSION:3.0
93 FN:First1 Last1
94 N:Last1;First1
95 NICKNAME:Firsty1
96 PHOTO:The Alphabet:
97 abcdefghijklmnop
98 qrstuvwsyz
99 BDAY:1999-12-05
100 ADR:Box111;Room 111;First Street,First Corner;Cityone;First State;11111;Country
101 LABEL:Label 1
102 TEL:+11111111
103 EMAIL:first1@provider1
104 MAILER:Wanderlust1
105 TZ:+01:00
106 GEO:37.386013;-122.082932
107 TITLE:Director\\, Research and Development
108 ROLE:Programmer
109 LOGO:encoded logo #1
110 AGENT:CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
111 ORG:Company1;Unit1;Subunit1
112 CATEGORIES:category1
113 NOTE:This vcard uses every type defined in rfc2426.
114 PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
115 REV:1995-10-31T22:27:10Z
116 SORT-STRING:aaa000
117 SOUND:Audible1
118 UID:111-111-111-111
119 URL:http://first1.host1.org
120 CLASS:CONFIDENTIAL
121 KEY:The Key No 1
122 X-foo:extended type 1
123 END:VCARD
125 ["First1" "Last1"
126 ("Firsty1")
127 "Company1
128 Unit1
129 Subunit1"
130 (["Office" "+11111111"])
131 (["Office"
132 ("Box111" "Room 111" "First Street" "First Corner")
133 "Cityone"
134 "First State"
135 "11111"
136 "Country"])
137 ("first1@provider1")
138 ((x-foo . "extended type 1")
139 (key . "The Key No 1")
140 (class . "CONFIDENTIAL")
141 (uid . "111-111-111-111")
142 (sound . "Audible1")
143 (sort-string . "aaa000")
144 (prodid . "-//ONLINE DIRECTORY//NONSGML Version 1//EN")
145 (agent . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
146 (logo . "encoded logo #1")
147 (role . "Programmer")
148 (title . "Director, Research and Development")
149 (geo . "37.386013;-122.082932")
150 (tz . "+01:00")
151 (mailer . "Wanderlust1")
152 (label . "Label 1")
153 (photo . "The Alphabet:abcdefghijklmnopqrstuvwsyz")
154 (mail-alias . "category1")
155 (anniversary . "1999-12-05 birthday")
156 (notes . "This vcard uses every type defined in rfc2426.")
157 (www . "http://first1.host1.org")
158 (creation-date . "1995-10-31T22:27:10Z") (timestamp . "2010-03-04"))]
159 "First1 Last1"
160 nil nil t)
163 (bbdb-vcard-import-test
165 ** Bad vCard: semi-colons where they don't belong
166 ------------------------------------------------------------
167 BEGIN:VCARD
168 VERSION:3.0
169 FN:First2; Last2
170 N:Last2;First2
171 NICKNAME:Firsty2,or; something
172 PHOTO:The Alphabet:
173 abcdefghij;klmnop
174 qrstuvwsyz
175 BDAY:1999-12-05
176 ADR:Box111;Room 111;First Street,First Corner;Cityone;First State;11111;Country
177 LABEL:Label 1;Label 2
178 TEL:+11111111;+222222
179 EMAIL:first1@provider1
180 MAILER:Wanderlust1;Wanderlust2
181 TZ:+01:00;Here
182 GEO:37.386013;-122.082932
183 TITLE:Director\\, Research; and Development
184 ROLE:Programmer
185 LOGO:encoded logo #1
186 AGENT:CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
187 ORG:Company1;Unit1;Subunit1
188 CATEGORIES:category1
189 NOTE:This isn't a decent vCard. It shouldn't render our bbdb unusable. We don't expect it to re-import unchanged, though.
190 REV:1995-10-31T22:27:10Z
191 SORT-STRING:aaa000
192 SOUND:Audible1
193 UID:111-111-111-111
194 URL:http://first1.host1.org; My home
195 CLASS:CONFIDENTIAL
196 KEY:The Key No 1
197 X-foo:extended type 1
198 END:VCARD
200 ["First2" "Last2"
201 ("First2; Last2" "Firsty2" "or; something")
202 "Company1
203 Unit1
204 Subunit1"
205 (["Office" "+11111111;+222222"])
206 (["Office" ("Box111" "Room 111" "First Street" "First Corner") "Cityone" "First State" "11111" "Country"])
207 ("first1@provider1")
208 ((x-foo . "extended type 1")
209 (key . "The Key No 1")
210 (class . "CONFIDENTIAL")
211 (uid . "111-111-111-111")
212 (sound . "Audible1")
213 (sort-string . "aaa000")
214 (agent . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
215 (logo . "encoded logo #1")
216 (role . "Programmer")
217 (title . "Director, Research; and Development")
218 (geo . "37.386013;-122.082932")
219 (tz . "+01:00;Here")
220 (mailer . "Wanderlust1;Wanderlust2")
221 (label . "Label 1;Label 2")
222 (photo . "The Alphabet:abcdefghij;klmnopqrstuvwsyz")
223 (mail-alias . "category1")
224 (anniversary . "1999-12-05 birthday")
225 (notes . "This isn't a decent vCard. It shouldn't render our bbdb unusable. We don't expect it to re-import unchanged, though.")
226 (www . "http://first1.host1.org; My home")
227 (creation-date . "1995-10-31T22:27:10Z") (timestamp . "2010-03-04"))]
228 "First2 Last2"
229 nil nil t)
232 (bbdb-vcard-import-test
234 ** The following is made of examples from rfc2426.
235 ------------------------------------------------------------
236 BEGIN:VCARD
237 VERSION:3.0
238 FN:Mr. John Q. Public\\, Esq.
239 N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
240 NICKNAME:Robbie
241 PHOTO;VALUE=uri:http://www.abc.com/pub/photos
242 /jqpublic.gif
243 BDAY:1996-04-15
244 ADR;TYPE=dom,home,postal,parcel:;;123 Main
245 Street;Any Town;CA;91921-1234
246 LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\\, Esq.\\n
247 Mail Drop: TNE QB\\n123 Main Street\\nAny Town\\, CA 91921-1234
248 \\nU.S.A.
249 TEL;TYPE=work,voice,pref,msg:+1-213-555-1234
250 EMAIL;TYPE=internet:jqpublic@xyz.dom1.com
251 EMAIL;TYPE=internet:jdoe@isp.net
252 MAILER:PigeonMail 2.1
253 TZ:-05:00
254 GEO:37.386013;-122.082932
255 TITLE:Director\\, Research and Development
256 ROLE:Programmer
257 LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
258 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
259 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
260 AGENT;VALUE=uri:
261 CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
262 ORG:ABC\\, Inc.;North American Division;Marketing
263 CATEGORIES:TRAVEL AGENT
264 NOTE:This fax number is operational 0800 to 1715
265 EST\\, Mon-Fri.
266 PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
267 REV:1995-10-31T22:27:10Z
268 SOUND;TYPE=BASIC;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
269 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
270 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
271 UID:19950401-080045-40000F192713-0052
272 URL:http://www.swbyps.restaurant.french/~chezchic.html
273 CLASS:PUBLIC
274 KEY;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQA
275 wdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYX
276 Rpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
277 ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNj
278 E5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYD
279 VQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAx
280 MPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRz
281 Y2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQ
282 EBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2
283 dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MB
284 EGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau
285 +hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIP
286 mx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//y
287 rZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7
288 UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==
289 END:VCARD
291 ["Dr. John Philip Paul" "Stevenson Jr. M.D. A.C.P."
292 ("Mr. John Q. Public, Esq." "Robbie")
293 "ABC, Inc.
294 North American Division
295 Marketing"
296 (["Office" "+1-213-555-1234"])
297 (["Home"
298 ("123 Main Street")
299 "Any Town"
300 "CA"
301 "91921-1234"
302 ""])
303 ("jqpublic@xyz.dom1.com" "jdoe@isp.net")
304 ((key\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==")
305 (class . "PUBLIC")
306 (uid . "19950401-080045-40000F192713-0052")
307 (sound\;type=basic\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
308 (prodid . "-//ONLINE DIRECTORY//NONSGML Version 1//EN")
309 (agent\;value=uri . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
310 (logo\;encoding=b\;type=jpeg . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
311 (role . "Programmer")
312 (title . "Director, Research and Development")
313 (geo . "37.386013;-122.082932")
314 (tz . "-05:00")
315 (mailer . "PigeonMail 2.1")
316 (label\;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
317 Mail Drop: TNE QB
318 123 Main Street
319 Any Town, CA 91921-1234
320 U.S.A.")
321 (photo\;value=uri . "http://www.abc.com/pub/photos/jqpublic.gif")
322 (mail-alias . "TRAVEL AGENT")
323 (anniversary . "1996-04-15 birthday")
324 (notes . "This fax number is operational 0800 to 1715 EST, Mon-Fri.")
325 (www . "http://www.swbyps.restaurant.french/~chezchic.html")
326 (creation-date . "1995-10-31T22:27:10Z") (timestamp . "2010-03-04"))]
327 "John"
328 nil nil t)
331 (bbdb-vcard-import-test
333 ** Exactly the same as before.
334 Re-reading it shouldn't duplicate anything.
335 ------------------------------------------------------------
336 BEGIN:VCARD
337 VERSION:3.0
338 FN:Mr. John Q. Public\\, Esq.
339 N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
340 NICKNAME:Robbie
341 PHOTO;VALUE=uri:http://www.abc.com/pub/photos
342 /jqpublic.gif
343 BDAY:1996-04-15
344 ADR;TYPE=dom,home,postal,parcel:;;123 Main
345 Street;Any Town;CA;91921-1234
346 LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\\, Esq.\\n
347 Mail Drop: TNE QB\\n123 Main Street\\nAny Town\\, CA 91921-1234
348 \\nU.S.A.
349 TEL;TYPE=work,voice,pref,msg:+1-213-555-1234
350 EMAIL;TYPE=internet:jqpublic@xyz.dom1.com
351 EMAIL;TYPE=internet:jdoe@isp.net
352 MAILER:PigeonMail 2.1
353 TZ:-05:00
354 GEO:37.386013;-122.082932
355 TITLE:Director\\, Research and Development
356 ROLE:Programmer
357 LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
358 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
359 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
360 AGENT;VALUE=uri:
361 CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
362 ORG:ABC\\, Inc.;North American Division;Marketing
363 CATEGORIES:TRAVEL AGENT
364 NOTE:This fax number is operational 0800 to 1715
365 EST\\, Mon-Fri.
366 PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
367 REV:1995-10-31T22:27:10Z
368 SOUND;TYPE=BASIC;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
369 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
370 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
371 UID:19950401-080045-40000F192713-0052
372 URL:http://www.swbyps.restaurant.french/~chezchic.html
373 CLASS:PUBLIC
374 KEY;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQA
375 wdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYX
376 Rpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
377 ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNj
378 E5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYD
379 VQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAx
380 MPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRz
381 Y2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQ
382 EBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2
383 dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MB
384 EGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau
385 +hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIP
386 mx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//y
387 rZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7
388 UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==
389 END:VCARD
391 ["Dr. John Philip Paul" "Stevenson Jr. M.D. A.C.P."
392 ("Mr. John Q. Public, Esq." "Robbie")
393 "ABC, Inc.
394 North American Division
395 Marketing"
396 (["Office" "+1-213-555-1234"])
397 (["Home"
398 ("123 Main Street")
399 "Any Town"
400 "CA"
401 "91921-1234"
402 ""])
403 ("jqpublic@xyz.dom1.com" "jdoe@isp.net")
404 ((key\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==")
405 (class . "PUBLIC")
406 (uid . "19950401-080045-40000F192713-0052")
407 (sound\;type=basic\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
408 (prodid . "-//ONLINE DIRECTORY//NONSGML Version 1//EN")
409 (agent\;value=uri . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
410 (logo\;encoding=b\;type=jpeg . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
411 (role . "Programmer")
412 (title . "Director, Research and Development")
413 (geo . "37.386013;-122.082932")
414 (tz . "-05:00")
415 (mailer . "PigeonMail 2.1")
416 (label\;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
417 Mail Drop: TNE QB
418 123 Main Street
419 Any Town, CA 91921-1234
420 U.S.A.")
421 (photo\;value=uri . "http://www.abc.com/pub/photos/jqpublic.gif")
422 (www . "http://www.swbyps.restaurant.french/~chezchic.html")
423 (mail-alias . "TRAVEL AGENT")
424 (anniversary . "1996-04-15 birthday")
425 (notes . "This fax number is operational 0800 to 1715 EST, Mon-Fri.")
426 (creation-date . "1995-10-31T22:27:10Z") (timestamp . "2010-03-04"))]
427 "John"
428 nil nil t)
431 (bbdb-vcard-import-test
433 ** Re-use of existing BBDB entries.
434 *** N, ORG, EMAIL
435 ------------------------------------------------------------
436 BEGIN:VCARD
437 VERSION:3.0
438 N:FamilyA;FirstA
439 ORG:OrgA;UnitA
440 EMAIL:userA@hostA.example.com
441 END:vcard
443 ["FirstA" "FamilyA"
445 "OrgA
446 UnitA"
449 ("userA@hostA.example.com")
450 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
451 "FirstA FamilyA")
454 (bbdb-vcard-import-test
456 *** The same again; shouldn't change the previous one.
457 ------------------------------------------------------------
458 BEGIN:VCARD
459 VERSION:3.0
460 N:FamilyA;FirstA
461 ORG:OrgA;UnitA
462 EMAIL:userA@hostA.example.com
463 END:VCARD
465 ["FirstA" "FamilyA"
467 "OrgA
468 UnitA"
471 ("userA@hostA.example.com")
472 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
473 "FirstA FamilyA")
476 (bbdb-vcard-import-test
478 *** Same N, same ORG, different EMAIL, which should be added to the previous
479 one.
480 ------------------------------------------------------------
481 BEGIN:VCARD
482 VERSION:3.0
483 N:FamilyA;FirstA
484 ORG:OrgA;UnitA
485 EMAIL:personA@example.com
486 END:VCARD
488 ["FirstA" "FamilyA"
490 "OrgA
491 UnitA"
494 ("userA@hostA.example.com" "personA@example.com")
495 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
496 "FirstA FamilyA")
499 (bbdb-vcard-import-test
501 *** Same N, same ORG, no EMAIL; shouldn't change anything.
502 ------------------------------------------------------------
503 BEGIN:VCARD
504 VERSION:3.0
505 N:FamilyA;FirstA
506 ORG:OrgA;UnitA
507 END:VCARD
509 ["FirstA" "FamilyA"
511 "OrgA
512 UnitA"
515 ("userA@hostA.example.com" "personA@example.com")
516 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
517 "FirstA FamilyA")
520 (bbdb-vcard-import-test
522 *** Same N, same EMAIL, no ORG; shouldn't change anything.
523 ------------------------------------------------------------
524 BEGIN:VCARD
525 VERSION:3.0
526 N:FamilyA;FirstA
527 EMAIL:userA@hostA.example.com
528 END:VCARD
530 ["FirstA" "FamilyA"
532 "OrgA
533 UnitA"
536 ("userA@hostA.example.com" "personA@example.com")
537 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
538 "FirstA FamilyA")
541 (bbdb-vcard-import-test
543 *** Same N, same EMAIL, different ORG by which Company of the previous one
544 should be replaced.
545 ------------------------------------------------------------
546 BEGIN:VCARD
547 VERSION:3.0
548 N:FamilyA;FirstA
549 ORG:OrgA;UnitB
550 EMAIL:userA@hostA.example.com
551 END:VCARD
553 ["FirstA" "FamilyA"
555 "OrgA
556 UnitB"
559 ("userA@hostA.example.com" "personA@example.com")
560 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
561 "FirstA FamilyA")
564 (bbdb-vcard-import-test
566 *** Different N, same EMAIL, same ORG; should go into a fresh entry.
567 ------------------------------------------------------------
568 BEGIN:VCARD
569 VERSION:3.0
570 N:FamilyA1;FirstA1
571 ORG:OrgA;UnitB
572 EMAIL:userA@hostA.example.com
573 END:VCARD
575 ["FirstA1" "FamilyA1"
577 "OrgA
578 UnitB"
581 ("userA@hostA.example.com")
582 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
583 "FirstA1 FamilyA1")
587 (bbdb-vcard-import-test
589 ** AKA has various sources; duplicates are being discarded.
590 ------------------------------------------------------------
591 BEGIN:VCARD
592 VERSION:3.0
593 N:FamilyB;FirstB
594 A.N:PseudonymB;FirstB
595 FN:The FirstB of FamilyB
596 A.FN:FirstB1 FamilyB1
597 B.FN:FirstB2 FamilyB2
598 C.FN:FirstB FamilyB
599 NICKNAME:Bee,Effy Bee,FirstB FamilyB
600 END:VCARD
602 ["FirstB" "FamilyB"
603 ("FirstB2 FamilyB2"
604 "FirstB1 FamilyB1"
605 "The FirstB of FamilyB"
606 "FirstB PseudonymB"
607 "Bee"
608 "Effy Bee")
613 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
614 "FirstB FamilyB")
617 (bbdb-vcard-import-test
619 ** Additional ORGs go to Notes, org.
620 ------------------------------------------------------------
621 BEGIN:VCARD
622 VERSION:3.0
623 N:FamilyC;FirstC
624 ORG:OrgC1
625 ORG:OrgC2
626 END:vcard
628 ["FirstC" "FamilyC"
630 "OrgC1"
634 ((org . "OrgC2")
635 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
636 "FirstC FamilyC")
639 (bbdb-vcard-import-test
641 *** ... but only if they are unique
642 ------------------------------------------------------------
643 BEGIN:VCARD
644 VERSION:3.0
645 N:FamilyC;FirstC
646 ORG:OrgC1
647 ORG:OrgC2
648 ORG:OrgC3
649 ORG:OrgC3
650 ORG:OrgC4
651 END:VCARD
653 ["FirstC" "FamilyC"
655 "OrgC1"
659 ((org . "OrgC4")
660 (org . "OrgC3")
661 (org . "OrgC2")
662 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
663 "FirstC FamilyC")
666 (bbdb-vcard-import-test
668 ** Prefixes are discarded.
669 ------------------------------------------------------------
670 X.BEGIN:VCARD
671 X.VERSION:3.0
672 X.N:FamilyD;FirstD
673 X.ORG:OrgD;UnitD
674 X.EMAIL:userD@hostD.example.com
675 X.END:VCARD
677 ["FirstD" "FamilyD"
679 "OrgD
680 UnitD"
683 ("userD@hostD.example.com")
684 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
685 "FirstD FamilyD")
688 (bbdb-vcard-import-test
690 *** Same as before, don't change anything.
691 ------------------------------------------------------------
692 BEGIN:VCARD
693 VERSION:3.0
694 N:FamilyD;FirstD
695 ORG:OrgD;UnitD
696 EMAIL:userD@hostD.example.com
697 END:VCARD
699 ["FirstD" "FamilyD"
701 "OrgD
702 UnitD"
705 ("userD@hostD.example.com")
706 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
707 "FirstD FamilyD")
710 (bbdb-vcard-import-test
712 *** Same as before, don't change anything.
713 ------------------------------------------------------------
714 Y.BEGIN:VCARD
715 Y.VERSION:3.0
716 Y.N:FamilyD;FirstD
717 Y.ORG:OrgD;UnitD
718 Y.EMAIL:userD@hostD.example.com
719 Y.END:VCARD
721 ["FirstD" "FamilyD"
723 "OrgD
724 UnitD"
727 ("userD@hostD.example.com")
728 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
729 "FirstD FamilyD")
732 (bbdb-vcard-import-test
734 ** Case Insensitivity
735 ------------------------------------------------------------
736 BEGIN:Vcard
737 Version:3.0
738 n:FamilyE;FirstE
739 Org:OrgE;UnitE
740 email:userE@hostE.example.com
741 end:vcard
743 ["FirstE" "FamilyE"
745 "OrgE
746 UnitE"
749 ("userE@hostE.example.com")
750 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
751 "FirstE FamilyE")
754 (bbdb-vcard-import-test
756 ** Non-ASCII Content
757 ------------------------------------------------------------
758 BEGIN:VCARD
759 VERSION:3.0
760 FN:Franz Rübezahl
761 N:Rübezahl;Franz
762 NICKNAME:Fränzchen,Rübe
763 ADR:Postschließfach 17;Zimmer Zwölf;Einbahnstraße;Ödstadt;;75480;
764 ORG:Rübe AG
765 END:VCARD
767 ["Franz" "Rübezahl"
768 ("Fränzchen" "Rübe")
769 "Rübe AG"
771 (["Office"
772 ("Postschließfach 17" "Zimmer Zwölf" "Einbahnstraße")
773 "Ödstadt"
775 "75480"
776 ""])
778 ((creation-date . "2010-03-06") (timestamp . "2010-03-06")) ]
779 "Rübe")
782 (bbdb-vcard-import-test
784 *** Multiple, structured ADR
785 ------------------------------------------------------------
786 BEGIN:VCARD
787 VERSION:3.0
788 N:FamilyF;FirstF
789 ORG:OrgF;UnitF
790 ADR;TYPE=dom,home,postal,parcel:Box111,LHS;Room 111,or not;First Street,First Corner;Cityone;First State;11111,22222;Country
791 ADR;TYPE=intl,work,postal,parcel:Box222,RHS;Room 22,or something;Second Street,First Corner;Citytwo;Second State;222,33333;Country
792 ADR;TYPE=dom,work,postal,parcel:;;Second Street,First Corner;Citytwo;;222,33333;
793 ADR;TYPE=intl;TYPE=home;TYPE=parcel:;;Third Street,First Corner;Citythree;;222,33333;
794 END:VCARD
796 ["FirstF" "FamilyF"
798 "OrgF
799 UnitF"
801 (["Home"
802 ("Box111" "LHS" "Room 111" "or not" "First Street" "First Corner")
803 "Cityone"
804 "First State"
805 "11111\n22222"
806 "Country"]
807 ["Office"
808 ("Box222" "RHS" "Room 22" "or something" "Second Street" "First Corner")
809 "Citytwo"
810 "Second State"
811 "222\n33333"
812 "Country"]
813 ["Office"
814 ("Second Street" "First Corner")
815 "Citytwo"
817 "222\n33333"
819 ["Home"
820 ("Third Street" "First Corner")
821 "Citythree"
823 "222\n33333"
824 ""])
826 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
827 "FirstF FamilyF")
830 (bbdb-vcard-import-test
832 *** Skip types from bbdb-vcard-skip-on-import
833 ------------------------------------------------------------
834 BEGIN:VCARD
835 VERSION:3.0
836 N:FamilyH;FirstH
837 ORG:OrgH;UnitH
838 EMAIL:userH@hostH.example.com
839 X-GSM-FOO:Blah
840 X-GSM-BAR:Blahblah
841 END:VCARD
843 ["FirstH" "FamilyH"
845 "OrgH
846 UnitH"
849 ("userH@hostH.example.com")
850 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
851 "FirstH FamilyH")
854 (bbdb-vcard-import-test
856 *** Skip empty types.
857 ------------------------------------------------------------
858 BEGIN:VCARD
859 VERSION:3.0
860 N:FamilyG;FirstG
861 ORG:OrgG;UnitG
862 EMAIL:userG@hostG.example.com
863 ROLE:
864 TITLE:
865 GEO:
866 END:VCARD
868 ["FirstG" "FamilyG"
870 "OrgG
871 UnitG"
874 ("userG@hostG.example.com")
875 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
876 "FirstG FamilyG")
879 (bbdb-vcard-import-test
881 *** Remove X-BBDB- prefixes
882 ------------------------------------------------------------
883 BEGIN:VCARD
884 VERSION:3.0
885 N:FamilyN;FirstN
886 ORG:OrgN;UnitN
887 EMAIL:userN@hostN.example.com
888 X-BBDB-MARK-CHAR:b
889 X-BBDB-TEX-NAME:{\\\\em FirstM FamilyM}
890 END:VCARD
892 ["FirstN" "FamilyN"
894 "OrgN
895 UnitN"
898 ("userN@hostN.example.com")
899 ((tex-name . "{\\em FirstM FamilyM}")
900 (mark-char . "b")
901 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
902 "FirstN FamilyN")
905 (bbdb-vcard-import-test
907 ** Merging of vcard NOTEs
908 *** A vcard with two NOTEs.
909 ------------------------------------------------------------
910 BEGIN:VCARD
911 VERSION:3.0
912 N:FamilyI;FirstI
913 ORG:OrgI
914 NOTE:Note No. 1a
915 NOTE:Note No. 1b
916 END:VCARD
918 ["FirstI" "FamilyI"
920 "OrgI"
924 ((notes . "Note No. 1a;\nNote No. 1b")
925 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
926 "FirstI FamilyI")
929 (bbdb-vcard-import-test
931 *** Same as before, but a different NOTE.
932 ------------------------------------------------------------
933 BEGIN:VCARD
934 VERSION:3.0
935 N:FamilyI;FirstI
936 ORG:OrgI
937 NOTE:Note No. 2
938 END:VCARD
940 ["FirstI" "FamilyI"
942 "OrgI"
946 ((notes . "Note No. 1a;\nNote No. 1b;\nNote No. 2")
947 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
948 "FirstI FamilyI")
951 (bbdb-vcard-import-test
953 *** Same as before, but a NOTE we've seen already
954 ------------------------------------------------------------
955 BEGIN:VCARD
956 VERSION:3.0
957 N:FamilyI;FirstI
958 ORG:OrgI
959 NOTE:Note No. 1b
960 END:VCARD
962 ["FirstI" "FamilyI"
964 "OrgI"
968 ((notes . "Note No. 1a;\nNote No. 1b;\nNote No. 2")
969 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
970 "FirstI FamilyI")
974 (bbdb-vcard-import-test
976 ** Merging of vcard CATEGORIES
977 *** A vcard with two CATEGORIES.
978 ------------------------------------------------------------
979 BEGIN:VCARD
980 VERSION:3.0
981 N:FamilyM;FirstM
982 ORG:OrgI
983 CATEGORIES:Category 1a,Category 1b
984 CATEGORIES:Category 2a,Category 2b
985 END:VCARD
987 ["FirstM" "FamilyM"
989 "OrgI"
993 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b")
994 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
995 "FirstM FamilyM")
998 (bbdb-vcard-import-test
1000 *** Same as before, but a different CATEGORIES.
1001 ------------------------------------------------------------
1002 BEGIN:VCARD
1003 VERSION:3.0
1004 N:FamilyM;FirstM
1005 ORG:OrgI
1006 CATEGORIES:Category 3
1007 END:VCARD
1009 ["FirstM" "FamilyM"
1011 "OrgI"
1015 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
1016 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1017 "FirstM FamilyM")
1020 (bbdb-vcard-import-test
1022 *** Same as before, but a CATEGORIES we've seen already
1023 ------------------------------------------------------------
1024 BEGIN:VCARD
1025 VERSION:3.0
1026 N:FamilyM;FirstM
1027 ORG:OrgI
1028 CATEGORIES:Category 2b
1029 END:VCARD
1031 ["FirstM" "FamilyM"
1033 "OrgI"
1037 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
1038 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1039 "FirstM FamilyM")
1042 (bbdb-vcard-import-test
1044 ** A vcard with two other vcards inside; we check the outer one
1045 ------------------------------------------------------------
1046 BEGIN:VCARD
1047 VERSION:3.0
1048 FN:OuterfirstA OuterlastA
1049 N:OuterlastA OuterfirstA
1050 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
1051 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1052 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
1053 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
1054 NOTE:A note
1055 END:VCARD
1057 ["OuterlastA" "OuterfirstA"
1058 ("OuterfirstA OuterlastA")
1063 ((b\.agent . "BEGIN:VCARD
1064 VERSION:3.0
1065 N:InnerlastB;InnerfirstB
1066 FN:InnerfirstB InnerlastB
1067 TEL:+1-919-555-1234
1068 EMAIL;TYPE=INTERNET:InnerB@hostB.com
1069 END:VCARD
1071 (agent . "BEGIN:VCARD
1072 VERSION:3.0
1073 N:InnerlastA;InnerfirstA
1074 FN:InnerfirstA InnerlastA
1075 TEL:+1-919-555-1234
1076 EMAIL;TYPE=INTERNET:InnerA@hostA.com
1077 END:VCARD
1079 (notes . "A note")
1080 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1081 "OuterfirstA OuterlastA")
1084 (bbdb-vcard-import-test
1086 ** A vcard with two other vcards inside; we check the first inner one
1087 ------------------------------------------------------------
1088 BEGIN:VCARD
1089 VERSION:3.0
1090 FN:OuterfirstA OuterlastA
1091 N:OuterlastA OuterfirstA
1092 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
1093 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1094 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
1095 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
1096 NOTE:A note
1097 END:VCARD
1099 ["InnerfirstA" "InnerlastA"
1102 (["Office" "+1-919-555-1234"])
1104 ("InnerA@hostA.com")
1105 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1106 "InnerfirstA InnerlastA")
1109 (bbdb-vcard-import-test
1111 ** A vcard with two other vcards inside; we check the second inner one
1112 ------------------------------------------------------------
1113 BEGIN:VCARD
1114 VERSION:3.0
1115 FN:OuterfirstA OuterlastA
1116 N:OuterlastA OuterfirstA
1117 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
1118 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1119 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
1120 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
1121 NOTE:A note
1122 END:VCARD
1124 ["InnerfirstB" "InnerlastB"
1127 (["Office" "+1-919-555-1234"])
1129 ("InnerB@hostB.com")
1130 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1131 "InnerfirstB InnerlastB")
1134 (bbdb-vcard-import-test
1136 ** Treatment of REV
1137 *** Store REV as creation-date in new records...
1138 ------------------------------------------------------------
1139 BEGIN:VCARD
1140 VERSION:3.0
1141 N:FamilyJ;FirstJ
1142 ORG:OrgJ
1143 REV:1997-03-27T22:27:10Z
1144 END:VCARD
1146 ["FirstJ" "FamilyJ"
1148 "OrgJ"
1152 ((creation-date . "1997-03-27T22:27:10Z") (timestamp . "2010-03-04")) ]
1153 "FirstJ FamilyJ"
1154 nil nil t)
1157 (bbdb-vcard-import-test
1159 *** ...but not in existing records
1160 ------------------------------------------------------------
1161 BEGIN:VCARD
1162 VERSION:3.0
1163 N:FamilyJ;FirstJ
1164 ORG:OrgJ
1165 REV:1977-12-03T22:27:10Z
1166 END:VCARD
1168 ["FirstJ" "FamilyJ"
1170 "OrgJ"
1174 ((creation-date . "1997-03-27T22:27:10Z") (timestamp . "2010-03-04")) ]
1175 "FirstJ FamilyJ"
1176 nil nil t)
1179 (bbdb-vcard-import-test
1181 *** The same, but dashless REV
1182 ------------------------------------------------------------
1183 BEGIN:VCARD
1184 VERSION:3.0
1185 N:FamilyR;FirstR
1186 ORG:OrgR
1187 REV:19771203T222710Z
1188 END:VCARD
1190 ["FirstR" "FamilyR"
1192 "OrgR"
1196 ((creation-date . "1977-12-03T22:27:10Z") (timestamp . "2010-03-04")) ]
1197 "FirstR FamilyR"
1198 nil nil t)
1202 (bbdb-vcard-import-test
1204 ** Matching BDAY and N induce merge
1205 *** Storing a new person
1206 ------------------------------------------------------------
1207 BEGIN:VCARD
1208 VERSION:3.0
1209 N:FamilyK;FirstK
1210 ORG:CompanyK
1211 BDAY:1927-03-27
1212 END:VCARD
1214 ["FirstK" "FamilyK"
1216 "CompanyK"
1220 ((anniversary . "1927-03-27 birthday")
1221 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1222 "FirstK FamilyK")
1225 (bbdb-vcard-import-test
1227 *** Not quite the same person: BDAY differs.
1228 ------------------------------------------------------------
1229 BEGIN:VCARD
1230 VERSION:3.0
1231 N:FamilyK;FirstK
1232 ORG:CompanyK2
1233 BDAY:1937-04-28
1234 END:VCARD
1236 ["FirstK" "FamilyK"
1238 "CompanyK2"
1242 ((anniversary . "1937-04-28 birthday")
1243 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1244 "FirstK FamilyK"
1245 "CompanyK2")
1248 (bbdb-vcard-import-test
1250 *** Known person due to matching BDAY. Different ORG, though.
1251 ------------------------------------------------------------
1252 BEGIN:VCARD
1253 VERSION:3.0
1254 N:FamilyK;FirstK
1255 ORG:CompanyK1
1256 BDAY:1927-03-27
1257 END:VCARD
1259 ["FirstK" "FamilyK"
1261 "CompanyK1"
1265 ((anniversary . "1927-03-27 birthday")
1266 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1267 "FirstK FamilyK"
1268 "CompanyK1")
1271 (bbdb-vcard-import-test
1273 *** Known person due to matching BDAY (albeit in another date format). Different ORG, again.
1274 ------------------------------------------------------------
1275 BEGIN:VCARD
1276 VERSION:3.0
1277 N:FamilyK;FirstK
1278 ORG:CompanyK3
1279 BDAY:19270327
1280 END:VCARD
1282 ["FirstK" "FamilyK"
1284 "CompanyK3"
1288 ((anniversary . "1927-03-27 birthday")
1289 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1290 "FirstK FamilyK"
1291 "CompanyK3")
1295 (bbdb-vcard-import-test
1297 *** Anniversaries
1298 ** Birthdays include time.
1299 ------------------------------------------------------------
1300 BEGIN:VCARD
1301 VERSION:3.0
1302 N:FamilyP;FirstP
1303 BDAY:1927-03-27T23:44:54Z
1304 END:VCARD
1306 ["FirstP" "FamilyP"
1312 ((anniversary . "1927-03-27T23:44:54Z birthday")
1313 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1314 "FirstP FamilyP")
1317 (bbdb-vcard-import-test
1319 ** Birthdays include time (half-obsolete format).
1320 ------------------------------------------------------------
1321 BEGIN:VCARD
1322 VERSION:3.0
1323 N:FamilyQ;FirstQ
1324 BDAY:19580327T234454
1325 END:VCARD
1327 ["FirstQ" "FamilyQ"
1333 ((anniversary . "1958-03-27T23:44:54 birthday")
1334 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1335 "FirstQ FamilyQ")
1338 (bbdb-vcard-import-test
1340 ** Non-birthday anniversaries
1341 ------------------------------------------------------------
1342 BEGIN:VCARD
1343 VERSION:3.0
1344 N:FamilyM;FirstM
1345 BDAY:1927-03-27
1346 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah\\n1998-03-12 %s created bbdb-anniv.el %d years ago
1347 END:VCARD
1349 ["FirstM" "FamilyM"
1355 ((anniversary . "1927-03-27 birthday\n1960-12-12 wedding\n1970-11-11 blah\n1998-03-12 %s created bbdb-anniv.el %d years ago")
1356 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1357 "FirstM FamilyM")
1360 (bbdb-vcard-import-test
1362 ** Non-birthday anniversaries, no BDAY
1363 ------------------------------------------------------------
1364 BEGIN:VCARD
1365 VERSION:3.0
1366 N:FamilyN;FirstN
1367 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah
1368 END:VCARD
1370 ["FirstN" "FamilyN"
1376 ((anniversary . "1960-12-12 wedding\n1970-11-11 blah")
1377 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1378 "FirstN FamilyN")
1382 (bbdb-vcard-import-test
1384 ** No BDAY, but unlabelled birthday in anniversary
1385 ------------------------------------------------------------
1386 BEGIN:VCARD
1387 VERSION:3.0
1388 N:FamilyO;FirstO
1389 X-BBDB-ANNIVERSARY:1960-12-12\\n1970-11-11 blah
1390 NOTE:On re-import, birthday gets labelled.
1391 Therefore, re-import test of this one should fail.
1392 END:VCARD
1394 ["FirstO" "FamilyO"
1400 ((anniversary . "1960-12-12\n1970-11-11 blah")
1401 (notes . "On re-import, birthday gets labelled. Therefore, re-import test of this one should fail.")
1402 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1403 "FirstO FamilyO")
1407 (bbdb-vcard-import-test
1409 ** Matching TEL and N induce merge
1410 *** Storing a new person
1411 ------------------------------------------------------------
1412 BEGIN:VCARD
1413 VERSION:3.0
1414 N:FamilyL;FirstL
1415 TEL;TYPE=work:111100001
1416 TEL;TYPE=home:111100002
1417 TEL:111100003
1418 ORG:CompanyL
1419 END:VCARD
1421 ["FirstL" "FamilyL"
1423 "CompanyL"
1424 (["Office" "111100001"]
1425 ["Home" "111100002"]
1426 ["Office" "111100003"]
1430 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1431 "FirstL FamilyL")
1434 (bbdb-vcard-import-test
1436 *** Not quite the same person: no matching TEL.
1437 ------------------------------------------------------------
1438 BEGIN:VCARD
1439 VERSION:3.0
1440 N:FamilyL;FirstL
1441 TEL;TYPE=work:222200001
1442 TEL;TYPE=home:222200002
1443 TEL:222200003
1444 ORG:CompanyL2
1445 END:VCARD
1447 ["FirstL" "FamilyL"
1449 "CompanyL2"
1450 (["Office" "222200001"]
1451 ["Home" "222200002"]
1452 ["Office" "222200003"])
1455 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1456 "FirstL FamilyL"
1457 "CompanyL2")
1460 (bbdb-vcard-import-test
1462 *** Known person: matching TEL (but different ORG).
1463 ------------------------------------------------------------
1464 BEGIN:VCARD
1465 VERSION:3.0
1466 N:FamilyL;FirstL
1467 TEL;TYPE=work:333300001
1468 TEL;TYPE=work:111100002
1469 TEL:333300003
1470 ORG:CompanyL3
1471 END:VCARD
1473 ["FirstL" "FamilyL"
1475 "CompanyL3"
1476 (["Office" "111100003"]
1477 ["Home" "111100002"]
1478 ["Office" "111100001"]
1479 ["Office" "333300001"]
1480 ["Office" "111100002"]
1481 ["Office" "333300003"])
1484 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1485 "FirstL FamilyL"
1486 "CompanyL3")
1490 (bbdb-vcard-import-test
1492 ** From RFC 2426: author's address. Note the omission or type N
1493 which is declared mandatory by this very RFC.
1494 ------------------------------------------------------------
1495 BEGIN:vCard
1496 VERSION:3.0
1497 FN:Frank Dawson
1498 ORG:Lotus Development Corporation
1499 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
1500 ;Raleigh;NC;27613-3502;U.S.A.
1501 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
1502 TEL;TYPE=FAX,WORK:+1-919-676-9564
1503 EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com
1504 EMAIL;TYPE=INTERNET:fdawson@earthlink.net
1505 URL:http://home.earthlink.net/~fdawson
1506 END:vCard
1508 ["" ""
1509 ("Frank Dawson")
1510 "Lotus Development Corporation"
1511 (["Office" "+1-919-676-9515"] ["Office" "+1-919-676-9564"])
1512 (["Office"
1513 ("6544 Battleford Drive")
1514 "Raleigh"
1515 "NC"
1516 "27613-3502"
1517 "U.S.A."])
1518 ("Frank_Dawson@Lotus.com" "fdawson@earthlink.net")
1519 ((www . "http://home.earthlink.net/~fdawson")
1520 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1521 "Frank Dawson")
1523 (bbdb-vcard-import-test
1525 ** The other author of RFC 2426
1526 ------------------------------------------------------------
1527 BEGIN:vCard
1528 VERSION:3.0
1529 FN:Tim Howes
1530 ORG:Netscape Communications Corp.
1531 ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;
1532 CA; 94043;U.S.A.
1533 TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419
1534 TEL;TYPE=FAX,WORK:+1-415-528-4164
1535 EMAIL;TYPE=INTERNET:howes@netscape.com
1536 END:vCard
1538 ["" ""
1539 ("Tim Howes")
1540 "Netscape Communications Corp."
1541 (["Office" "+1-415-937-3419"]
1542 ["Office" "+1-415-528-4164"])
1543 (["Office"
1544 ("501 E. Middlefield Rd.")
1545 "Mountain View"
1546 "CA"
1547 " 94043"
1548 "U.S.A."])
1549 ("howes@netscape.com")
1550 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1551 "Tim Howes")
1555 (bbdb-vcard-import-test
1557 ** vCard version 2.1
1558 ------------------------------------------------------------
1559 BEGIN:VCARD
1560 VERSION:2.1
1561 N:Friday;Fred
1562 TEL;WORK;VOICE:+1-213-555-1234
1563 TEL;WORK;FAX:+1-213-555-5678
1564 BDAY:19661221t173745
1565 END:VCARD
1567 ["Fred" "Friday"
1570 (["Office" "+1-213-555-1234"]
1571 ["Office" "+1-213-555-5678"])
1574 ((anniversary . "1966-12-21T17:37:45 birthday") (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1575 "Fred Friday")
1578 (bbdb-vcard-import-test
1580 ** vCard version 2.1
1581 *** Case insensitivity
1582 ------------------------------------------------------------
1583 begin:VCARD
1584 version:2.1
1585 n:Thursday;Tom
1586 tel;WORK;VOICE:+1-213-555-1234
1587 tel;WORK;FAX:+1-213-555-5678
1588 end:VCARD
1590 ["Tom" "Thursday"
1593 (["Office" "+1-213-555-1234"]
1594 ["Office" "+1-213-555-5678"])
1597 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1598 "Tom Thursday")
1601 (bbdb-vcard-import-test
1603 ** vCard version 2.1
1604 ------------------------------------------------------------
1605 BEGIN:VCARD
1606 VERSION:2.1
1607 N:Smith;John;M.;Mr.;Esq.
1608 TEL;WORK;VOICE;MSG:+1 (919) 555-1234
1609 TEL;CELL:+1 (919) 554-6758
1610 TEL;WORK;FAX:+1 (919) 555-9876
1611 ADR;WORK;PARCEL;POSTAL;DOM:Suite 101;1 Central St.;AnyTown;NC;27654
1612 END:VCARD
1614 ["Mr. John M." "Smith Esq."
1617 (["Office" "+1 (919) 555-1234"]
1618 ["Mobile" "+1 (919) 554-6758"]
1619 ["Office" "+1 (919) 555-9876"])
1620 (["Office" ("Suite 101" "1 Central St." "AnyTown") "NC" "27654" "" ""])
1622 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1623 "Smith")
1626 (bbdb-vcard-import-test
1628 ** vCard version 2.1
1629 *** Quoted-printable
1630 ------------------------------------------------------------
1631 BEGIN:VCARD
1632 VERSION:2.1
1633 N:Doe;John;;;
1634 FN:John Doe
1635 ORG:Doe Company, The;
1636 TITLE: President
1637 NOTE;ENCODING=QUOTED-PRINTABLE: This is a note associated
1638 with this contact=0D=0A
1639 TEL;WORK;VOICE:(987) 123-4567
1640 TEL;HOME;VOICE:(987) 765-4321
1641 TEL;CELL;VOICE:(987) 135-8642
1642 TEL;WORK;FAX:(987) 246-1357
1643 ADR;WORK:;;1234 North Street;Anytown;TX 751234;;United States
1644 of America
1645 LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1234 North Street=0D=0AAnytown,
1646 TX 751234 =0D=0AUnited States of America
1647 URL:
1648 URL:<WWLINK TYPE=\"GENERIC\"
1649 VALUE=\"http://www.doeweb.com\">http://www.doeweb.com</WWLINK>
1650 EMAIL;PREF;INTERNET:jdoe@nowhere.com
1651 REV:19980114T170559Z
1652 END:VCARD
1654 ["John" "Doe"
1656 "Doe Company, The
1658 (["Office" "(987) 123-4567"]
1659 ["Home" "(987) 765-4321"]
1660 ["Mobile" "(987) 135-8642"]
1661 ["Office" "(987) 246-1357"])
1662 (["Office" ("1234 North Street") "Anytown" "TX 751234" "" "United States of America"])
1663 ("jdoe@nowhere.com")
1664 ((label\;type=work . "1234 North Street
1665 Anytown, TX 751234
1666 United States of America")
1667 (title . "President")
1668 (notes . "This is a note associated with this contact
1670 (www . "http://www.doeweb.com")
1671 (creation-date . "1998-01-14T17:05:59Z") (timestamp . "2010-03-04"))]
1672 "John Doe"
1673 nil nil t)
1677 (bbdb-vcard-import-test
1679 ** A v2.1 vcard with another vcard inside; we check the outer one
1680 ------------------------------------------------------------
1681 BEGIN:VCARD
1682 VERSION:2.1
1683 N:Outerlast2A; Outerfirst2A
1684 FN:Outerfirst2A Outerlast2A
1685 AGENT:BEGIN:VCARD\\nVERSION:2.1\\nN:Innerlast2A\\;Innerfirst2A\\nFN:Innerfirst2A Innerlast2A\\nTEL:+1-919-555-
1686 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1687 NOTE:A note
1688 END:VCARD
1690 [" Outerfirst2A" "Outerlast2A"
1691 ("Outerfirst2A Outerlast2A")
1696 ((agent . "BEGIN:VCARD\\
1697 VERSION:2.1\\
1698 N:Innerlast2A\\;Innerfirst2A\\
1699 FN:Innerfirst2A Innerlast2A\\
1700 TEL:+1-919-555-1234\\
1701 EMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\
1702 END:VCARD\\
1704 (notes . "A note")
1705 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1706 "Outerfirst2A Outerlast2A")
1709 (bbdb-vcard-import-test
1711 ** A v2.1 vcard with another vcard inside; we check the inner one
1712 ------------------------------------------------------------
1713 BEGIN:VCARD
1714 VERSION:2.1
1715 N:Outerlast2A Outerfirst2A
1716 AGENT:BEGIN:VCARD\\nVERSION:2.1\\nN:Innerlast2A\\;Innerfirst2A\\nFN:Innerfirst2A Innerlast2A\\nTEL:+1-919-555-
1717 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1718 NOTE:A note
1719 END:VCARD
1721 ["Innerfirst2A" "Innerlast2A"
1724 (["Office" "+1-919-555-1234"])
1726 ("InnerA@hostA.com")
1727 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1728 "Innerfirst2A Innerlast2A")
1732 ;;;; The Export/Re-Import Tests
1733 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1735 (bbdb "" nil)
1736 (with-current-buffer "*BBDB*"
1737 (bbdb-vcard-export "/tmp/test-bbdb-0.vcf" t nil))
1739 (let ((first-bbdb (bbdb-search (bbdb-records) ""))
1740 second-bbdb)
1741 (bbdb-save-db)
1742 (save-buffer bbdb-buffer)
1743 (kill-buffer bbdb-buffer)
1744 (kill-buffer "*BBDB*")
1745 (delete-file "/tmp/test-bbdb")
1746 (bbdb-vcard-import-file "/tmp/test-bbdb-0.vcf")
1747 (setq second-bbdb (bbdb-search (bbdb-records) ""))
1748 (bbdb-vcard-compare-bbdbs first-bbdb second-bbdb))
1749 ;; FIXME: previous line messes bbdb up.