Included vcard.el by Noah Friedman
[bbdb-vcard.git] / test-bbdb-vcard.el
blob9977d16381667e3337d53be075786419a67c6288
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-31") (timestamp . "2010-03-04"))]
159 "First1 Last1"
160 nil nil t)
163 (bbdb-vcard-import-test
165 ** The following is made of examples from rfc2426.
166 ------------------------------------------------------------
167 BEGIN:VCARD
168 VERSION:3.0
169 FN:Mr. John Q. Public\\, Esq.
170 N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
171 NICKNAME:Robbie
172 PHOTO;VALUE=uri:http://www.abc.com/pub/photos
173 /jqpublic.gif
174 BDAY:1996-04-15
175 ADR;TYPE=dom,home,postal,parcel:;;123 Main
176 Street;Any Town;CA;91921-1234
177 LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\\, Esq.\\n
178 Mail Drop: TNE QB\\n123 Main Street\\nAny Town\\, CA 91921-1234
179 \\nU.S.A.
180 TEL;TYPE=work,voice,pref,msg:+1-213-555-1234
181 EMAIL;TYPE=internet:jqpublic@xyz.dom1.com
182 EMAIL;TYPE=internet:jdoe@isp.net
183 MAILER:PigeonMail 2.1
184 TZ:-05:00
185 GEO:37.386013;-122.082932
186 TITLE:Director\\, Research and Development
187 ROLE:Programmer
188 LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
189 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
190 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
191 AGENT;VALUE=uri:
192 CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
193 ORG:ABC\\, Inc.;North American Division;Marketing
194 CATEGORIES:TRAVEL AGENT
195 NOTE:This fax number is operational 0800 to 1715
196 EST\\, Mon-Fri.
197 PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
198 REV:1995-10-31T22:27:10Z
199 SOUND;TYPE=BASIC;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
200 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
201 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
202 UID:19950401-080045-40000F192713-0052
203 URL:http://www.swbyps.restaurant.french/~chezchic.html
204 CLASS:PUBLIC
205 KEY;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQA
206 wdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYX
207 Rpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
208 ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNj
209 E5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYD
210 VQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAx
211 MPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRz
212 Y2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQ
213 EBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2
214 dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MB
215 EGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau
216 +hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIP
217 mx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//y
218 rZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7
219 UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==
220 END:VCARD
222 ["Dr. John Philip Paul" "Stevenson Jr. M.D. A.C.P."
223 ("Mr. John Q. Public, Esq." "Robbie")
224 "ABC, Inc.
225 North American Division
226 Marketing"
227 (["Office" "+1-213-555-1234"])
228 (["Home"
229 ("123 Main Street")
230 "Any Town"
231 "CA"
232 "91921-1234"
233 ""])
234 ("jqpublic@xyz.dom1.com" "jdoe@isp.net")
235 ((key\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==")
236 (class . "PUBLIC")
237 (uid . "19950401-080045-40000F192713-0052")
238 (sound\;type=basic\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
239 (prodid . "-//ONLINE DIRECTORY//NONSGML Version 1//EN")
240 (agent\;value=uri . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
241 (logo\;encoding=b\;type=jpeg . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
242 (role . "Programmer")
243 (title . "Director, Research and Development")
244 (geo . "37.386013;-122.082932")
245 (tz . "-05:00")
246 (mailer . "PigeonMail 2.1")
247 (label\;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
248 Mail Drop: TNE QB
249 123 Main Street
250 Any Town, CA 91921-1234
251 U.S.A.")
252 (photo\;value=uri . "http://www.abc.com/pub/photos/jqpublic.gif")
253 (mail-alias . "TRAVEL AGENT")
254 (anniversary . "1996-04-15 birthday")
255 (notes . "This fax number is operational 0800 to 1715 EST, Mon-Fri.")
256 (www . "http://www.swbyps.restaurant.french/~chezchic.html")
257 (creation-date . "1995-10-31") (timestamp . "2010-03-04"))]
258 "John"
259 nil nil t)
262 (bbdb-vcard-import-test
264 ** Exactly the same as before.
265 Re-reading it shouldn't duplicate anything.
266 ------------------------------------------------------------
267 BEGIN:VCARD
268 VERSION:3.0
269 FN:Mr. John Q. Public\\, Esq.
270 N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
271 NICKNAME:Robbie
272 PHOTO;VALUE=uri:http://www.abc.com/pub/photos
273 /jqpublic.gif
274 BDAY:1996-04-15
275 ADR;TYPE=dom,home,postal,parcel:;;123 Main
276 Street;Any Town;CA;91921-1234
277 LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\\, Esq.\\n
278 Mail Drop: TNE QB\\n123 Main Street\\nAny Town\\, CA 91921-1234
279 \\nU.S.A.
280 TEL;TYPE=work,voice,pref,msg:+1-213-555-1234
281 EMAIL;TYPE=internet:jqpublic@xyz.dom1.com
282 EMAIL;TYPE=internet:jdoe@isp.net
283 MAILER:PigeonMail 2.1
284 TZ:-05:00
285 GEO:37.386013;-122.082932
286 TITLE:Director\\, Research and Development
287 ROLE:Programmer
288 LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
289 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
290 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
291 AGENT;VALUE=uri:
292 CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
293 ORG:ABC\\, Inc.;North American Division;Marketing
294 CATEGORIES:TRAVEL AGENT
295 NOTE:This fax number is operational 0800 to 1715
296 EST\\, Mon-Fri.
297 PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
298 REV:1995-10-31T22:27:10Z
299 SOUND;TYPE=BASIC;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
300 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
301 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
302 UID:19950401-080045-40000F192713-0052
303 URL:http://www.swbyps.restaurant.french/~chezchic.html
304 CLASS:PUBLIC
305 KEY;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQA
306 wdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYX
307 Rpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
308 ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNj
309 E5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYD
310 VQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAx
311 MPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRz
312 Y2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQ
313 EBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2
314 dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MB
315 EGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau
316 +hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIP
317 mx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//y
318 rZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7
319 UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==
320 END:VCARD
322 ["Dr. John Philip Paul" "Stevenson Jr. M.D. A.C.P."
323 ("Mr. John Q. Public, Esq." "Robbie")
324 "ABC, Inc.
325 North American Division
326 Marketing"
327 (["Office" "+1-213-555-1234"])
328 (["Home"
329 ("123 Main Street")
330 "Any Town"
331 "CA"
332 "91921-1234"
333 ""])
334 ("jqpublic@xyz.dom1.com" "jdoe@isp.net")
335 ((key\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==")
336 (class . "PUBLIC")
337 (uid . "19950401-080045-40000F192713-0052")
338 (sound\;type=basic\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
339 (prodid . "-//ONLINE DIRECTORY//NONSGML Version 1//EN")
340 (agent\;value=uri . "CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com")
341 (logo\;encoding=b\;type=jpeg . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0")
342 (role . "Programmer")
343 (title . "Director, Research and Development")
344 (geo . "37.386013;-122.082932")
345 (tz . "-05:00")
346 (mailer . "PigeonMail 2.1")
347 (label\;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
348 Mail Drop: TNE QB
349 123 Main Street
350 Any Town, CA 91921-1234
351 U.S.A.")
352 (photo\;value=uri . "http://www.abc.com/pub/photos/jqpublic.gif")
353 (www . "http://www.swbyps.restaurant.french/~chezchic.html")
354 (mail-alias . "TRAVEL AGENT")
355 (anniversary . "1996-04-15 birthday")
356 (notes . "This fax number is operational 0800 to 1715 EST, Mon-Fri.")
357 (creation-date . "1995-10-31") (timestamp . "2010-03-04"))]
358 "John"
359 nil nil t)
362 (bbdb-vcard-import-test
364 ** Re-use of existing BBDB entries.
365 *** N, ORG, EMAIL
366 ------------------------------------------------------------
367 BEGIN:VCARD
368 VERSION:3.0
369 N:FamilyA;FirstA
370 ORG:OrgA;UnitA
371 EMAIL:userA@hostA.example.com
372 END:vcard
374 ["FirstA" "FamilyA"
376 "OrgA
377 UnitA"
380 ("userA@hostA.example.com")
381 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
382 "FirstA FamilyA")
385 (bbdb-vcard-import-test
387 *** The same again; shouldn't change the previous one.
388 ------------------------------------------------------------
389 BEGIN:VCARD
390 VERSION:3.0
391 N:FamilyA;FirstA
392 ORG:OrgA;UnitA
393 EMAIL:userA@hostA.example.com
394 END:VCARD
396 ["FirstA" "FamilyA"
398 "OrgA
399 UnitA"
402 ("userA@hostA.example.com")
403 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
404 "FirstA FamilyA")
407 (bbdb-vcard-import-test
409 *** Same N, same ORG, different EMAIL, which should be added to the previous
410 one.
411 ------------------------------------------------------------
412 BEGIN:VCARD
413 VERSION:3.0
414 N:FamilyA;FirstA
415 ORG:OrgA;UnitA
416 EMAIL:personA@example.com
417 END:VCARD
419 ["FirstA" "FamilyA"
421 "OrgA
422 UnitA"
425 ("userA@hostA.example.com" "personA@example.com")
426 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
427 "FirstA FamilyA")
430 (bbdb-vcard-import-test
432 *** Same N, same ORG, no EMAIL; shouldn't change anything.
433 ------------------------------------------------------------
434 BEGIN:VCARD
435 VERSION:3.0
436 N:FamilyA;FirstA
437 ORG:OrgA;UnitA
438 END:VCARD
440 ["FirstA" "FamilyA"
442 "OrgA
443 UnitA"
446 ("userA@hostA.example.com" "personA@example.com")
447 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
448 "FirstA FamilyA")
451 (bbdb-vcard-import-test
453 *** Same N, same EMAIL, no ORG; shouldn't change anything.
454 ------------------------------------------------------------
455 BEGIN:VCARD
456 VERSION:3.0
457 N:FamilyA;FirstA
458 EMAIL:userA@hostA.example.com
459 END:VCARD
461 ["FirstA" "FamilyA"
463 "OrgA
464 UnitA"
467 ("userA@hostA.example.com" "personA@example.com")
468 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
469 "FirstA FamilyA")
472 (bbdb-vcard-import-test
474 *** Same N, same EMAIL, different ORG by which Company of the previous one
475 should be replaced.
476 ------------------------------------------------------------
477 BEGIN:VCARD
478 VERSION:3.0
479 N:FamilyA;FirstA
480 ORG:OrgA;UnitB
481 EMAIL:userA@hostA.example.com
482 END:VCARD
484 ["FirstA" "FamilyA"
486 "OrgA
487 UnitB"
490 ("userA@hostA.example.com" "personA@example.com")
491 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
492 "FirstA FamilyA")
495 (bbdb-vcard-import-test
497 *** Different N, same EMAIL, same ORG; should go into a fresh entry.
498 ------------------------------------------------------------
499 BEGIN:VCARD
500 VERSION:3.0
501 N:FamilyA1;FirstA1
502 ORG:OrgA;UnitB
503 EMAIL:userA@hostA.example.com
504 END:VCARD
506 ["FirstA1" "FamilyA1"
508 "OrgA
509 UnitB"
512 ("userA@hostA.example.com")
513 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
514 "FirstA1 FamilyA1")
518 (bbdb-vcard-import-test
520 ** AKA has various sources; duplicates are being discarded.
521 ------------------------------------------------------------
522 BEGIN:VCARD
523 VERSION:3.0
524 N:FamilyB;FirstB
525 A.N:PseudonymB;FirstB
526 FN:The FirstB of FamilyB
527 A.FN:FirstB1 FamilyB1
528 B.FN:FirstB2 FamilyB2
529 C.FN:FirstB FamilyB
530 NICKNAME:Bee,Effy Bee,FirstB FamilyB
531 END:VCARD
533 ["FirstB" "FamilyB"
534 ("FirstB2 FamilyB2"
535 "FirstB1 FamilyB1"
536 "The FirstB of FamilyB"
537 "FirstB PseudonymB"
538 "Bee"
539 "Effy Bee")
544 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
545 "FirstB FamilyB")
548 (bbdb-vcard-import-test
550 ** Additional ORGs go to Notes, org.
551 ------------------------------------------------------------
552 BEGIN:VCARD
553 VERSION:3.0
554 N:FamilyC;FirstC
555 ORG:OrgC1
556 ORG:OrgC2
557 END:vcard
559 ["FirstC" "FamilyC"
561 "OrgC1"
565 ((org . "OrgC2")
566 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
567 "FirstC FamilyC")
570 (bbdb-vcard-import-test
572 *** ... but only if they are unique
573 ------------------------------------------------------------
574 BEGIN:VCARD
575 VERSION:3.0
576 N:FamilyC;FirstC
577 ORG:OrgC1
578 ORG:OrgC2
579 ORG:OrgC3
580 ORG:OrgC3
581 ORG:OrgC4
582 END:VCARD
584 ["FirstC" "FamilyC"
586 "OrgC1"
590 ((org . "OrgC4")
591 (org . "OrgC3")
592 (org . "OrgC2")
593 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
594 "FirstC FamilyC")
597 (bbdb-vcard-import-test
599 ** Prefixes are discarded.
600 ------------------------------------------------------------
601 X.BEGIN:VCARD
602 X.VERSION:3.0
603 X.N:FamilyD;FirstD
604 X.ORG:OrgD;UnitD
605 X.EMAIL:userD@hostD.example.com
606 X.END:VCARD
608 ["FirstD" "FamilyD"
610 "OrgD
611 UnitD"
614 ("userD@hostD.example.com")
615 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
616 "FirstD FamilyD")
619 (bbdb-vcard-import-test
621 *** Same as before, don't change anything.
622 ------------------------------------------------------------
623 BEGIN:VCARD
624 VERSION:3.0
625 N:FamilyD;FirstD
626 ORG:OrgD;UnitD
627 EMAIL:userD@hostD.example.com
628 END:VCARD
630 ["FirstD" "FamilyD"
632 "OrgD
633 UnitD"
636 ("userD@hostD.example.com")
637 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
638 "FirstD FamilyD")
641 (bbdb-vcard-import-test
643 *** Same as before, don't change anything.
644 ------------------------------------------------------------
645 Y.BEGIN:VCARD
646 Y.VERSION:3.0
647 Y.N:FamilyD;FirstD
648 Y.ORG:OrgD;UnitD
649 Y.EMAIL:userD@hostD.example.com
650 Y.END:VCARD
652 ["FirstD" "FamilyD"
654 "OrgD
655 UnitD"
658 ("userD@hostD.example.com")
659 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
660 "FirstD FamilyD")
663 (bbdb-vcard-import-test
665 ** Case Insensitivity
666 ------------------------------------------------------------
667 BEGIN:Vcard
668 Version:3.0
669 n:FamilyE;FirstE
670 Org:OrgE;UnitE
671 email:userE@hostE.example.com
672 end:vcard
674 ["FirstE" "FamilyE"
676 "OrgE
677 UnitE"
680 ("userE@hostE.example.com")
681 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
682 "FirstE FamilyE")
685 (bbdb-vcard-import-test
687 ** Non-ASCII Content
688 ------------------------------------------------------------
689 BEGIN:VCARD
690 VERSION:3.0
691 FN:Franz Rübezahl
692 N:Rübezahl;Franz
693 NICKNAME:Fränzchen,Rübe
694 ADR:Postschließfach 17;Zimmer Zwölf;Einbahnstraße;Ödstadt;;75480;
695 ORG:Rübe AG
696 END:VCARD
698 ["Franz" "Rübezahl"
699 ("Fränzchen" "Rübe")
700 "Rübe AG"
702 (["Office"
703 ("Postschließfach 17" "Zimmer Zwölf" "Einbahnstraße")
704 "Ödstadt"
706 "75480"
707 ""])
709 ((creation-date . "2010-03-06") (timestamp . "2010-03-06")) ]
710 "Rübe")
713 (bbdb-vcard-import-test
715 *** Multiple, structured ADR
716 ------------------------------------------------------------
717 BEGIN:VCARD
718 VERSION:3.0
719 N:FamilyF;FirstF
720 ORG:OrgF;UnitF
721 ADR;TYPE=dom,home,postal,parcel:Box111,LHS;Room 111,or not;First Street,First Corner;Cityone;First State;11111,22222;Country
722 ADR;TYPE=intl,work,postal,parcel:Box222,RHS;Room 22,or something;Second Street,First Corner;Citytwo;Second State;222,33333;Country
723 ADR;TYPE=dom,work,postal,parcel:;;Second Street,First Corner;Citytwo;;222,33333;
724 ADR;TYPE=intl;TYPE=home;TYPE=parcel:;;Third Street,First Corner;Citythree;;222,33333;
725 END:VCARD
727 ["FirstF" "FamilyF"
729 "OrgF
730 UnitF"
732 (["Home"
733 ("Box111" "LHS" "Room 111" "or not" "First Street" "First Corner")
734 "Cityone"
735 "First State"
736 "11111\n22222"
737 "Country"]
738 ["Office"
739 ("Box222" "RHS" "Room 22" "or something" "Second Street" "First Corner")
740 "Citytwo"
741 "Second State"
742 "222\n33333"
743 "Country"]
744 ["Office"
745 ("Second Street" "First Corner")
746 "Citytwo"
748 "222\n33333"
750 ["Home"
751 ("Third Street" "First Corner")
752 "Citythree"
754 "222\n33333"
755 ""])
757 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
758 "FirstF FamilyF")
761 (bbdb-vcard-import-test
763 *** Skip types from bbdb-vcard-skip-on-import
764 ------------------------------------------------------------
765 BEGIN:VCARD
766 VERSION:3.0
767 N:FamilyH;FirstH
768 ORG:OrgH;UnitH
769 EMAIL:userH@hostH.example.com
770 X-GSM-FOO:Blah
771 X-GSM-BAR:Blahblah
772 END:VCARD
774 ["FirstH" "FamilyH"
776 "OrgH
777 UnitH"
780 ("userH@hostH.example.com")
781 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
782 "FirstH FamilyH")
785 (bbdb-vcard-import-test
787 *** Skip empty types.
788 ------------------------------------------------------------
789 BEGIN:VCARD
790 VERSION:3.0
791 N:FamilyG;FirstG
792 ORG:OrgG;UnitG
793 EMAIL:userG@hostG.example.com
794 ROLE:
795 TITLE:
796 GEO:
797 END:VCARD
799 ["FirstG" "FamilyG"
801 "OrgG
802 UnitG"
805 ("userG@hostG.example.com")
806 ((creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
807 "FirstG FamilyG")
810 (bbdb-vcard-import-test
812 *** Remove X-BBDB- prefixes
813 ------------------------------------------------------------
814 BEGIN:VCARD
815 VERSION:3.0
816 N:FamilyN;FirstN
817 ORG:OrgN;UnitN
818 EMAIL:userN@hostN.example.com
819 X-BBDB-MARK-CHAR:b
820 X-BBDB-TEX-NAME:{\\\\em FirstM FamilyM}
821 END:VCARD
823 ["FirstN" "FamilyN"
825 "OrgN
826 UnitN"
829 ("userN@hostN.example.com")
830 ((tex-name . "{\\em FirstM FamilyM}")
831 (mark-char . "b")
832 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
833 "FirstN FamilyN")
836 (bbdb-vcard-import-test
838 ** Merging of vcard NOTEs
839 *** A vcard with two NOTEs.
840 ------------------------------------------------------------
841 BEGIN:VCARD
842 VERSION:3.0
843 N:FamilyI;FirstI
844 ORG:OrgI
845 NOTE:Note No. 1a
846 NOTE:Note No. 1b
847 END:VCARD
849 ["FirstI" "FamilyI"
851 "OrgI"
855 ((notes . "Note No. 1a;\nNote No. 1b")
856 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
857 "FirstI FamilyI")
860 (bbdb-vcard-import-test
862 *** Same as before, but a different NOTE.
863 ------------------------------------------------------------
864 BEGIN:VCARD
865 VERSION:3.0
866 N:FamilyI;FirstI
867 ORG:OrgI
868 NOTE:Note No. 2
869 END:VCARD
871 ["FirstI" "FamilyI"
873 "OrgI"
877 ((notes . "Note No. 1a;\nNote No. 1b;\nNote No. 2")
878 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
879 "FirstI FamilyI")
882 (bbdb-vcard-import-test
884 *** Same as before, but a NOTE we've seen already
885 ------------------------------------------------------------
886 BEGIN:VCARD
887 VERSION:3.0
888 N:FamilyI;FirstI
889 ORG:OrgI
890 NOTE:Note No. 1b
891 END:VCARD
893 ["FirstI" "FamilyI"
895 "OrgI"
899 ((notes . "Note No. 1a;\nNote No. 1b;\nNote No. 2")
900 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
901 "FirstI FamilyI")
905 (bbdb-vcard-import-test
907 ** Merging of vcard CATEGORIES
908 *** A vcard with two CATEGORIES.
909 ------------------------------------------------------------
910 BEGIN:VCARD
911 VERSION:3.0
912 N:FamilyM;FirstM
913 ORG:OrgI
914 CATEGORIES:Category 1a,Category 1b
915 CATEGORIES:Category 2a,Category 2b
916 END:VCARD
918 ["FirstM" "FamilyM"
920 "OrgI"
924 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b")
925 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
926 "FirstM FamilyM")
929 (bbdb-vcard-import-test
931 *** Same as before, but a different CATEGORIES.
932 ------------------------------------------------------------
933 BEGIN:VCARD
934 VERSION:3.0
935 N:FamilyM;FirstM
936 ORG:OrgI
937 CATEGORIES:Category 3
938 END:VCARD
940 ["FirstM" "FamilyM"
942 "OrgI"
946 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
947 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
948 "FirstM FamilyM")
951 (bbdb-vcard-import-test
953 *** Same as before, but a CATEGORIES we've seen already
954 ------------------------------------------------------------
955 BEGIN:VCARD
956 VERSION:3.0
957 N:FamilyM;FirstM
958 ORG:OrgI
959 CATEGORIES:Category 2b
960 END:VCARD
962 ["FirstM" "FamilyM"
964 "OrgI"
968 ((mail-alias . "Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
969 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
970 "FirstM FamilyM")
973 (bbdb-vcard-import-test
975 ** A vcard with two other vcards inside; we check the outer one
976 ------------------------------------------------------------
977 BEGIN:VCARD
978 VERSION:3.0
979 FN:OuterfirstA OuterlastA
980 N:OuterlastA OuterfirstA
981 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
982 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
983 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
984 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
985 NOTE:A note
986 END:VCARD
988 ["OuterlastA" "OuterfirstA"
989 ("OuterfirstA OuterlastA")
994 ((b\.agent . "BEGIN:VCARD
995 VERSION:3.0
996 N:InnerlastB;InnerfirstB
997 FN:InnerfirstB InnerlastB
998 TEL:+1-919-555-1234
999 EMAIL;TYPE=INTERNET:InnerB@hostB.com
1000 END:VCARD
1002 (agent . "BEGIN:VCARD
1003 VERSION:3.0
1004 N:InnerlastA;InnerfirstA
1005 FN:InnerfirstA InnerlastA
1006 TEL:+1-919-555-1234
1007 EMAIL;TYPE=INTERNET:InnerA@hostA.com
1008 END:VCARD
1010 (notes . "A note")
1011 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1012 "OuterfirstA OuterlastA")
1015 (bbdb-vcard-import-test
1017 ** A vcard with two other vcards inside; we check the first inner one
1018 ------------------------------------------------------------
1019 BEGIN:VCARD
1020 VERSION:3.0
1021 FN:OuterfirstA OuterlastA
1022 N:OuterlastA OuterfirstA
1023 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
1024 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1025 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
1026 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
1027 NOTE:A note
1028 END:VCARD
1030 ["InnerfirstA" "InnerlastA"
1033 (["Office" "+1-919-555-1234"])
1035 ("InnerA@hostA.com")
1036 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1037 "InnerfirstA InnerlastA")
1040 (bbdb-vcard-import-test
1042 ** A vcard with two other vcards inside; we check the second inner one
1043 ------------------------------------------------------------
1044 BEGIN:VCARD
1045 VERSION:3.0
1046 FN:OuterfirstA OuterlastA
1047 N:OuterlastA OuterfirstA
1048 AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastA\\;InnerfirstA\\nFN:InnerfirstA InnerlastA\\nTEL:+1-919-555-
1049 1234\\nEMAIL\\;TYPE=INTERNET:InnerA@hostA.com\\nEND:VCARD\\n
1050 B.AGENT:BEGIN:VCARD\\nVERSION:3.0\\nN:InnerlastB\\;InnerfirstB\\nFN:InnerfirstB InnerlastB\\nTEL:+1-919-555-
1051 1234\\nEMAIL\\;TYPE=INTERNET:InnerB@hostB.com\\nEND:VCARD\\n
1052 NOTE:A note
1053 END:VCARD
1055 ["InnerfirstB" "InnerlastB"
1058 (["Office" "+1-919-555-1234"])
1060 ("InnerB@hostB.com")
1061 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1062 "InnerfirstB InnerlastB")
1065 (bbdb-vcard-import-test
1067 ** Treatment of REV
1068 *** Store REV as creation-date in new records...
1069 ------------------------------------------------------------
1070 BEGIN:VCARD
1071 VERSION:3.0
1072 N:FamilyJ;FirstJ
1073 ORG:OrgJ
1074 REV:1997-03-27T22:27:10Z
1075 END:VCARD
1077 ["FirstJ" "FamilyJ"
1079 "OrgJ"
1083 ((creation-date . "1997-03-27") (timestamp . "2010-03-04")) ]
1084 "FirstJ FamilyJ"
1085 nil nil t)
1088 (bbdb-vcard-import-test
1090 *** ...but not in existing records
1091 ------------------------------------------------------------
1092 BEGIN:VCARD
1093 VERSION:3.0
1094 N:FamilyJ;FirstJ
1095 ORG:OrgJ
1096 REV:1977-12-03T22:27:10Z
1097 END:VCARD
1099 ["FirstJ" "FamilyJ"
1101 "OrgJ"
1105 ((creation-date . "1997-03-27") (timestamp . "2010-03-04")) ]
1106 "FirstJ FamilyJ"
1107 nil nil t)
1111 (bbdb-vcard-import-test
1113 ** Matching BDAY and N induce merge
1114 *** Storing a new person
1115 ------------------------------------------------------------
1116 BEGIN:VCARD
1117 VERSION:3.0
1118 N:FamilyK;FirstK
1119 ORG:CompanyK
1120 BDAY:1927-03-27
1121 END:VCARD
1123 ["FirstK" "FamilyK"
1125 "CompanyK"
1129 ((anniversary . "1927-03-27 birthday")
1130 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1131 "FirstK FamilyK")
1134 (bbdb-vcard-import-test
1136 *** Not quite the same person: BDAY differs.
1137 ------------------------------------------------------------
1138 BEGIN:VCARD
1139 VERSION:3.0
1140 N:FamilyK;FirstK
1141 ORG:CompanyK2
1142 BDAY:1937-04-28
1143 END:VCARD
1145 ["FirstK" "FamilyK"
1147 "CompanyK2"
1151 ((anniversary . "1937-04-28 birthday")
1152 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1153 "FirstK FamilyK"
1154 "CompanyK2")
1157 (bbdb-vcard-import-test
1159 *** Known person due to matching BDAY. Different ORG, though.
1160 ------------------------------------------------------------
1161 BEGIN:VCARD
1162 VERSION:3.0
1163 N:FamilyK;FirstK
1164 ORG:CompanyK1
1165 BDAY:1927-03-27
1166 END:VCARD
1168 ["FirstK" "FamilyK"
1170 "CompanyK1"
1174 ((anniversary . "1927-03-27 birthday")
1175 (creation-date . "2010-03-04") (timestamp . "2010-03-04")) ]
1176 "FirstK FamilyK"
1177 "CompanyK1")
1181 (bbdb-vcard-import-test
1183 *** Anniversaries
1184 ** Non-birthday anniversaries
1185 ------------------------------------------------------------
1186 BEGIN:VCARD
1187 VERSION:3.0
1188 N:FamilyM;FirstM
1189 BDAY:1927-03-27
1190 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah\\n1998-03-12 %s created bbdb-anniv.el %d years ago
1191 END:VCARD
1193 ["FirstM" "FamilyM"
1199 ((anniversary . "1927-03-27 birthday\n1960-12-12 wedding\n1970-11-11 blah\n1998-03-12 %s created bbdb-anniv.el %d years ago")
1200 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1201 "FirstM FamilyM")
1204 (bbdb-vcard-import-test
1206 ** Non-birthday anniversaries, no BDAY
1207 ------------------------------------------------------------
1208 BEGIN:VCARD
1209 VERSION:3.0
1210 N:FamilyN;FirstN
1211 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah
1212 END:VCARD
1214 ["FirstN" "FamilyN"
1220 ((anniversary . "1960-12-12 wedding\n1970-11-11 blah")
1221 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1222 "FirstN FamilyN")
1226 (bbdb-vcard-import-test
1228 ** No BDAY, but unlabelled birthday in anniversary
1229 ------------------------------------------------------------
1230 BEGIN:VCARD
1231 VERSION:3.0
1232 N:FamilyO;FirstO
1233 X-BBDB-ANNIVERSARY:1960-12-12\\n1970-11-11 blah
1234 NOTE:On re-import, birthday gets labelled.
1235 Therefore, re-import test of this one should fail.
1236 END:VCARD
1238 ["FirstO" "FamilyO"
1244 ((anniversary . "1960-12-12\n1970-11-11 blah")
1245 (notes . "On re-import, birthday gets labelled. Therefore, re-import test of this one should fail.")
1246 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1247 "FirstO FamilyO")
1251 (bbdb-vcard-import-test
1253 ** Matching TEL and N induce merge
1254 *** Storing a new person
1255 ------------------------------------------------------------
1256 BEGIN:VCARD
1257 VERSION:3.0
1258 N:FamilyL;FirstL
1259 TEL;TYPE=work:111100001
1260 TEL;TYPE=home:111100002
1261 TEL:111100003
1262 ORG:CompanyL
1263 END:VCARD
1265 ["FirstL" "FamilyL"
1267 "CompanyL"
1268 (["Office" "111100001"]
1269 ["Home" "111100002"]
1270 ["Office" "111100003"]
1274 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1275 "FirstL FamilyL")
1278 (bbdb-vcard-import-test
1280 *** Not quite the same person: no matching TEL.
1281 ------------------------------------------------------------
1282 BEGIN:VCARD
1283 VERSION:3.0
1284 N:FamilyL;FirstL
1285 TEL;TYPE=work:222200001
1286 TEL;TYPE=home:222200002
1287 TEL:222200003
1288 ORG:CompanyL2
1289 END:VCARD
1291 ["FirstL" "FamilyL"
1293 "CompanyL2"
1294 (["Office" "222200001"]
1295 ["Home" "222200002"]
1296 ["Office" "222200003"])
1299 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1300 "FirstL FamilyL"
1301 "CompanyL2")
1304 (bbdb-vcard-import-test
1306 *** Known person: matching TEL (but different ORG).
1307 ------------------------------------------------------------
1308 BEGIN:VCARD
1309 VERSION:3.0
1310 N:FamilyL;FirstL
1311 TEL;TYPE=work:333300001
1312 TEL;TYPE=work:111100002
1313 TEL:333300003
1314 ORG:CompanyL3
1315 END:VCARD
1317 ["FirstL" "FamilyL"
1319 "CompanyL3"
1320 (["Office" "111100003"]
1321 ["Home" "111100002"]
1322 ["Office" "111100001"]
1323 ["Office" "333300001"]
1324 ["Office" "111100002"]
1325 ["Office" "333300003"])
1328 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1329 "FirstL FamilyL"
1330 "CompanyL3")
1334 (bbdb-vcard-import-test
1336 ** From RFC 2426: author's address. Note the omission or type N
1337 which is declared mandatory by this very RFC.
1338 ------------------------------------------------------------
1339 BEGIN:vCard
1340 VERSION:3.0
1341 FN:Frank Dawson
1342 ORG:Lotus Development Corporation
1343 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
1344 ;Raleigh;NC;27613-3502;U.S.A.
1345 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
1346 TEL;TYPE=FAX,WORK:+1-919-676-9564
1347 EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com
1348 EMAIL;TYPE=INTERNET:fdawson@earthlink.net
1349 URL:http://home.earthlink.net/~fdawson
1350 END:vCard
1352 ["" ""
1353 ("Frank Dawson")
1354 "Lotus Development Corporation"
1355 (["Office" "+1-919-676-9515"] ["Office" "+1-919-676-9564"])
1356 (["Office"
1357 ("6544 Battleford Drive")
1358 "Raleigh"
1359 "NC"
1360 "27613-3502"
1361 "U.S.A."])
1362 ("Frank_Dawson@Lotus.com" "fdawson@earthlink.net")
1363 ((www . "http://home.earthlink.net/~fdawson")
1364 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1365 "Frank Dawson")
1367 (bbdb-vcard-import-test
1369 ** The other author of RFC 2426
1370 ------------------------------------------------------------
1371 BEGIN:vCard
1372 VERSION:3.0
1373 FN:Tim Howes
1374 ORG:Netscape Communications Corp.
1375 ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;
1376 CA; 94043;U.S.A.
1377 TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419
1378 TEL;TYPE=FAX,WORK:+1-415-528-4164
1379 EMAIL;TYPE=INTERNET:howes@netscape.com
1380 END:vCard
1382 ["" ""
1383 ("Tim Howes")
1384 "Netscape Communications Corp."
1385 (["Office" "+1-415-937-3419"]
1386 ["Office" "+1-415-528-4164"])
1387 (["Office"
1388 ("501 E. Middlefield Rd.")
1389 "Mountain View"
1390 "CA"
1391 " 94043"
1392 "U.S.A."])
1393 ("howes@netscape.com")
1394 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1395 "Tim Howes")
1399 (bbdb-vcard-import-test
1401 ** vCard version 2.1 (coverted by convcard)
1402 ------------------------------------------------------------
1403 BEGIN:VCARD
1404 VERSION:2.1
1405 N:Friday;Fred
1406 TEL;WORK;VOICE:+1-213-555-1234
1407 TEL;WORK;FAX:+1-213-555-5678
1408 END:VCARD
1410 ["Fred" "Friday"
1413 (["Office" "+1-213-555-1234"]
1414 ["Office" "+1-213-555-5678"])
1417 ((creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1418 "Fred Friday")
1421 (bbdb-vcard-import-test
1423 ** vCard version 2.1 (coverted by convcard)
1424 ------------------------------------------------------------
1425 BEGIN:VCARD
1426 VERSION:2.1
1427 N:Smith;John;M.;Mr.;Esq.
1428 TEL;WORK;VOICE;MSG:+1 (919) 555-1234
1429 TEL;CELL:+1 (919) 554-6758
1430 TEL;WORK;FAX:+1 (919) 555-9876
1431 PHOTO;GIF;MIME:<<JOHNSMITH.part3.960129T083020.xyzMail@host3.com>
1432 ADR;WORK;PARCEL;POSTAL;DOM:Suite 101;1 Central St.;AnyTown;NC;27654
1433 END:VCARD
1435 ["Mr. John M." "Smith Esq."
1438 (["Office" "+1 (919) 555-1234"]
1439 ["Mobile" "+1 (919) 554-6758"]
1440 ["Office" "+1 (919) 555-9876"])
1441 (["Office" ("Suite 101" "1 Central St." "AnyTown") "NC" "27654" "" ""])
1443 ((photo\;type=image/gif . "<<JOHNSMITH.part3.960129T083020.xyzMail@host3.com>")
1444 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1445 "Smith")
1448 (bbdb-vcard-import-test
1450 ** vCard version 2.1 (coverted by convcard)
1451 *** Quoted-printable
1452 ------------------------------------------------------------
1453 BEGIN:VCARD
1454 VERSION:2.1
1455 N:Doe;John;;;
1456 FN:John Doe
1457 ORG:Doe Company, The;
1458 TITLE: President
1459 NOTE;ENCODING=QUOTED-PRINTABLE: This is a note associated
1460 with this contact=0D=0A
1461 TEL;WORK;VOICE:(987) 123-4567
1462 TEL;HOME;VOICE:(987) 765-4321
1463 TEL;CELL;VOICE:(987) 135-8642
1464 TEL;WORK;FAX:(987) 246-1357
1465 ADR;WORK:;;1234 North Street;Anytown;TX 751234;;United States
1466 of America
1467 LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1234 North Street=0D=0AAnytown,
1468 TX 751234 =0D=0AUnited States of America
1469 URL:
1470 URL:<WWLINK TYPE=\"GENERIC\"
1471 VALUE=\"http://www.doeweb.com\">http://www.doeweb.com</WWLINK>
1472 EMAIL;PREF;INTERNET:jdoe@nowhere.com
1473 REV:19980114T170559Z
1474 END:VCARD
1476 ["John" "Doe"
1478 "Doe Company, The"
1479 (["Office" "(987) 123-4567"]
1480 ["Home" "(987) 765-4321"]
1481 ["Mobile" "(987) 135-8642"]
1482 ["Office" "(987) 246-1357"])
1483 (["Office" ("1234 North Street") "Anytown" "TX 751234" "" "United States of America"])
1484 ("jdoe@nowhere.com")
1485 ((label\;type=work . "1234 North Street
1486 Anytown, TX 751234
1487 United States of America")
1488 (title . " President")
1489 (notes . " This is a note associated with this contact
1491 (www . "<WWLINK TYPE=\"GENERIC\"VALUE=\"http://www.doeweb.com\">http://www.doeweb.com</WWLINK>")
1492 (creation-date . "2010-03-04") (timestamp . "2010-03-04"))]
1493 "John Doe")
1498 ;;;; The Export/Re-Import Tests
1499 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1501 (bbdb "" nil)
1502 (with-current-buffer "*BBDB*"
1503 (bbdb-vcard-export "/tmp/test-bbdb-0.vcf" t nil))
1505 (let ((first-bbdb (bbdb-search (bbdb-records) ""))
1506 second-bbdb)
1507 (bbdb-save-db)
1508 (save-buffer bbdb-buffer)
1509 (kill-buffer bbdb-buffer)
1510 (kill-buffer "*BBDB*")
1511 (delete-file "/tmp/test-bbdb")
1512 (bbdb-vcard-import-file "/tmp/test-bbdb-0.vcf")
1513 (setq second-bbdb (bbdb-search (bbdb-records) ""))
1514 (bbdb-vcard-compare-bbdbs first-bbdb second-bbdb))
1515 ;; FIXME: previous line messes bbdb up.