1 ;;; Tests for bbdb-vcard.el
3 ;; Before proceeding, you should probably save your production bbdb file.
5 ;; To run the tests, eval this file.
6 ;; In case of failure, find test results in buffer `bbdb-vcard-test-result'.
8 ;; For the sake of minimality, not all test cases are rfc compliant.
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
""))
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
))
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)))
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'."
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")))
74 ;;; Try not to mess up our real BBDB:
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"))
85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
87 (bbdb-vcard-import-test
89 ** A vcard without any type parameters.
90 ------------------------------------------------------------
100 ADR:Box111;Room 111;First Street,First Corner;Cityone;First State;11111;Country
103 EMAIL:first1@provider1
106 GEO:37.386013;-122.082932
107 TITLE:Director\\, Research and Development
110 AGENT:CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
111 ORG:Company1;Unit1;Subunit1
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
119 URL:http://first1.host1.org
122 X-foo:extended type 1
130 (["Office" "+11111111"])
132 ("Box111" "Room 111" "First Street" "First Corner")
138 ((x-foo .
"extended type 1")
139 (key .
"The Key No 1")
140 (class .
"CONFIDENTIAL")
141 (uid .
"111-111-111-111")
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")
151 (mailer .
"Wanderlust1")
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"))]
163 (bbdb-vcard-import-test
165 ** The following is made of examples from rfc2426.
166 ------------------------------------------------------------
169 FN:Mr. John Q. Public\\, Esq.
170 N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
172 PHOTO;VALUE=uri:http://www.abc.com/pub/photos
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
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
185 GEO:37.386013;-122.082932
186 TITLE:Director\\, Research and Development
188 LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
189 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
190 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
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
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
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==
222 ["Dr. John Philip Paul" "Stevenson Jr. M.D. A.C.P."
223 ("Mr. John Q. Public, Esq." "Robbie")
225 North American Division
227 (["Office" "+1-213-555-1234"])
234 ("jqpublic@xyz.dom1.com" "jdoe@isp.net")
235 ((key\
;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==")
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")
246 (mailer .
"PigeonMail 2.1")
247 (label\
;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
250 Any Town
, CA
91921-
1234
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"))]
262 (bbdb-vcard-import-test
264 ** Exactly the same as before.
265 Re-reading it shouldn
't duplicate anything.
266 ------------------------------------------------------------
269 FN
:Mr. John Q. Public
\\, Esq.
270 N
:Stevenson
;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
272 PHOTO
;VALUE=uri:http://www.abc.com/pub/photos
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
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
285 GEO
:37.386013;-122.082932
286 TITLE
:Director
\\, Research and Development
288 LOGO
;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN
289 AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
290 ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
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
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
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
==
322 ["Dr. John Philip Paul
" "Stevenson Jr. M.D. A.C.P.
"
323 ("Mr. John Q. Public
, Esq.
" "Robbie
")
325 North American Division
327 (["Office
" "+1-
213-
555-
1234"])
334 ("jqpublic
@xyz.dom1.com
" "jdoe
@isp.net
")
335 ((key\;encoding=b . "MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk
/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG
+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB
/GV3jr3mcau
+hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM
+MSlhMfcpbTrONwNjZYW8vJDSoi
//yrZlVt9bJbs7MNYZVsyF1unsqaln4
/vy6Uawfg8VUMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ
==")
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")
346 (mailer .
"PigeonMail 2.1")
347 (label\
;type=dom\,home\,postal\,parcel . "Mr.John Q. Public, Esq.
350 Any Town
, CA
91921-
1234
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"))]
362 (bbdb-vcard-import-test
364 ** Re-use of existing BBDB entries.
366 ------------------------------------------------------------
371 EMAIL
:userA
@hostA.example.com
380 ("userA
@hostA.example.com
")
381 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
385 (bbdb-vcard-import-test
387 *** The same again
; shouldn't change the previous one.
388 ------------------------------------------------------------
393 EMAIL
:userA
@hostA.example.com
402 ("userA
@hostA.example.com
")
403 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
407 (bbdb-vcard-import-test
409 *** Same N
, same ORG
, different EMAIL
, which should be added to the previous
411 ------------------------------------------------------------
416 EMAIL
:personA
@example.com
425 ("userA
@hostA.example.com
" "personA
@example.com
")
426 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
430 (bbdb-vcard-import-test
432 *** Same N
, same ORG
, no EMAIL
; shouldn't change anything.
433 ------------------------------------------------------------
446 ("userA
@hostA.example.com
" "personA
@example.com
")
447 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
451 (bbdb-vcard-import-test
453 *** Same N
, same EMAIL
, no ORG
; shouldn't change anything.
454 ------------------------------------------------------------
458 EMAIL
:userA
@hostA.example.com
467 ("userA
@hostA.example.com
" "personA
@example.com
")
468 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
472 (bbdb-vcard-import-test
474 *** Same N
, same EMAIL
, different ORG by which Company of the previous one
476 ------------------------------------------------------------
481 EMAIL
:userA
@hostA.example.com
490 ("userA
@hostA.example.com
" "personA
@example.com
")
491 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
495 (bbdb-vcard-import-test
497 *** Different N
, same EMAIL
, same ORG
; should go into a fresh entry.
498 ------------------------------------------------------------
503 EMAIL
:userA
@hostA.example.com
506 ["FirstA1
" "FamilyA1
"
512 ("userA
@hostA.example.com
")
513 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
518 (bbdb-vcard-import-test
520 ** AKA has various sources
; duplicates are being discarded.
521 ------------------------------------------------------------
525 A.N
:PseudonymB
;FirstB
526 FN
:The FirstB of FamilyB
527 A.FN
:FirstB1 FamilyB1
528 B.FN
:FirstB2 FamilyB2
530 NICKNAME
:Bee
,Effy Bee
,FirstB FamilyB
536 "The FirstB of FamilyB
"
544 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04"))]
548 (bbdb-vcard-import-test
550 ** Additional ORGs go to Notes
, org.
551 ------------------------------------------------------------
566 (creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
570 (bbdb-vcard-import-test
572 *** ... but only if they are unique
573 ------------------------------------------------------------
593 (creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
597 (bbdb-vcard-import-test
599 ** Prefixes are discarded.
600 ------------------------------------------------------------
605 X.EMAIL
:userD
@hostD.example.com
614 ("userD
@hostD.example.com
")
615 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
619 (bbdb-vcard-import-test
621 *** Same as before
, don
't change anything.
622 ------------------------------------------------------------
627 EMAIL
:userD
@hostD.example.com
636 ("userD
@hostD.example.com
")
637 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
641 (bbdb-vcard-import-test
643 *** Same as before
, don
't change anything.
644 ------------------------------------------------------------
649 Y.EMAIL
:userD
@hostD.example.com
658 ("userD
@hostD.example.com
")
659 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
663 (bbdb-vcard-import-test
665 ** Case Insensitivity
666 ------------------------------------------------------------
671 email
:userE
@hostE.example.com
680 ("userE
@hostE.example.com
")
681 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
685 (bbdb-vcard-import-test
688 ------------------------------------------------------------
693 NICKNAME
:Fränzchen
,Rübe
694 ADR
:Postschließfach
17;Zimmer Zwölf;Einbahnstraße;Ödstadt;;75480;
699 ("Fränzchen
" "Rübe
")
703 ("Postschließfach
17" "Zimmer Zwölf
" "Einbahnstraße
")
709 ((creation-date . "2010-
03-
06") (timestamp . "2010-
03-
06")) ]
713 (bbdb-vcard-import-test
715 *** Multiple
, structured ADR
716 ------------------------------------------------------------
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;
733 ("Box111
" "LHS
" "Room
111" "or not
" "First Street
" "First Corner
")
739 ("Box222
" "RHS
" "Room
22" "or something
" "Second Street
" "First Corner
")
745 ("Second Street
" "First Corner
")
751 ("Third Street
" "First Corner
")
757 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04"))]
761 (bbdb-vcard-import-test
763 *** Skip types from bbdb-vcard-skip-on-import
764 ------------------------------------------------------------
769 EMAIL
:userH
@hostH.example.com
780 ("userH
@hostH.example.com
")
781 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
785 (bbdb-vcard-import-test
787 *** Skip empty types.
788 ------------------------------------------------------------
793 EMAIL
:userG
@hostG.example.com
805 ("userG
@hostG.example.com
")
806 ((creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04")) ]
810 (bbdb-vcard-import-test
812 *** Remove X-BBDB- prefixes
813 ------------------------------------------------------------
818 EMAIL
:userN
@hostN.example.com
820 X-BBDB-TEX-NAME
:{\\\\em FirstM FamilyM
}
829 ("userN
@hostN.example.com
")
830 ((tex-name . "{\\em FirstM FamilyM
}")
832 (creation-date . "2010-
03-
04") (timestamp . "2010-
03-
04"))]
836 (bbdb-vcard-import-test
838 ** Merging of vcard NOTEs
839 *** A vcard with two NOTEs.
840 ------------------------------------------------------------
855 ((notes . "Note No.
1a
;\nNote No. 1b")
856 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
860 (bbdb-vcard-import-test
862 *** Same as before, but a different NOTE.
863 ------------------------------------------------------------
877 ((notes .
"Note No. 1a;\nNote No. 1b;\nNote No. 2")
878 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
882 (bbdb-vcard-import-test
884 *** Same as before, but a NOTE we've seen already
885 ------------------------------------------------------------
899 ((notes .
"Note No. 1a;\nNote No. 1b;\nNote No. 2")
900 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
905 (bbdb-vcard-import-test
907 ** Merging of vcard CATEGORIES
908 *** A vcard with two CATEGORIES.
909 ------------------------------------------------------------
914 CATEGORIES:Category 1a,Category 1b
915 CATEGORIES:Category 2a,Category 2b
924 ((mail-alias .
"Category 1a,Category 1b,Category 2a,Category 2b")
925 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
929 (bbdb-vcard-import-test
931 *** Same as before, but a different CATEGORIES.
932 ------------------------------------------------------------
937 CATEGORIES:Category 3
946 ((mail-alias .
"Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
947 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
951 (bbdb-vcard-import-test
953 *** Same as before, but a CATEGORIES we've seen already
954 ------------------------------------------------------------
959 CATEGORIES:Category 2b
968 ((mail-alias .
"Category 1a,Category 1b,Category 2a,Category 2b,Category 3")
969 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
973 (bbdb-vcard-import-test
975 ** A vcard with two other vcards inside; we check the outer one
976 ------------------------------------------------------------
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
988 ["OuterlastA" "OuterfirstA"
989 ("OuterfirstA OuterlastA")
994 ((b\.agent .
"BEGIN:VCARD
996 N:InnerlastB;InnerfirstB
997 FN:InnerfirstB InnerlastB
999 EMAIL;TYPE=INTERNET:InnerB@hostB.com
1002 (agent .
"BEGIN:VCARD
1004 N:InnerlastA;InnerfirstA
1005 FN:InnerfirstA InnerlastA
1007 EMAIL;TYPE=INTERNET:InnerA@hostA.com
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 ------------------------------------------------------------
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
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 ------------------------------------------------------------
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
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
1068 *** Store REV as creation-date in new records...
1069 ------------------------------------------------------------
1074 REV:1997-03-27T22:27:10Z
1083 ((creation-date .
"1997-03-27") (timestamp .
"2010-03-04")) ]
1088 (bbdb-vcard-import-test
1090 *** ...but not in existing records
1091 ------------------------------------------------------------
1096 REV:1977-12-03T22:27:10Z
1105 ((creation-date .
"1997-03-27") (timestamp .
"2010-03-04")) ]
1111 (bbdb-vcard-import-test
1113 ** Matching BDAY and N induce merge
1114 *** Storing a new person
1115 ------------------------------------------------------------
1129 ((anniversary .
"1927-03-27 birthday")
1130 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
1134 (bbdb-vcard-import-test
1136 *** Not quite the same person: BDAY differs.
1137 ------------------------------------------------------------
1151 ((anniversary .
"1937-04-28 birthday")
1152 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
1157 (bbdb-vcard-import-test
1159 *** Known person due to matching BDAY. Different ORG, though.
1160 ------------------------------------------------------------
1174 ((anniversary .
"1927-03-27 birthday")
1175 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04")) ]
1181 (bbdb-vcard-import-test
1184 ** Non-birthday anniversaries
1185 ------------------------------------------------------------
1190 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah\\n1998-03-12 %s created bbdb-anniv.el %d years ago
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"))]
1204 (bbdb-vcard-import-test
1206 ** Non-birthday anniversaries, no BDAY
1207 ------------------------------------------------------------
1211 X-BBDB-ANNIVERSARY:1960-12-12 wedding\\n1970-11-11 blah
1220 ((anniversary .
"1960-12-12 wedding\n1970-11-11 blah")
1221 (creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
1226 (bbdb-vcard-import-test
1228 ** No BDAY, but unlabelled birthday in anniversary
1229 ------------------------------------------------------------
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.
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"))]
1251 (bbdb-vcard-import-test
1253 ** Matching TEL and N induce merge
1254 *** Storing a new person
1255 ------------------------------------------------------------
1259 TEL;TYPE=work:111100001
1260 TEL;TYPE=home:111100002
1268 (["Office" "111100001"]
1269 ["Home" "111100002"]
1270 ["Office" "111100003"]
1274 ((creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
1278 (bbdb-vcard-import-test
1280 *** Not quite the same person: no matching TEL.
1281 ------------------------------------------------------------
1285 TEL;TYPE=work:222200001
1286 TEL;TYPE=home:222200002
1294 (["Office" "222200001"]
1295 ["Home" "222200002"]
1296 ["Office" "222200003"])
1299 ((creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
1304 (bbdb-vcard-import-test
1306 *** Known person: matching TEL (but different ORG).
1307 ------------------------------------------------------------
1311 TEL;TYPE=work:333300001
1312 TEL;TYPE=work:111100002
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"))]
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 ------------------------------------------------------------
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
1354 "Lotus Development Corporation"
1355 (["Office" "+1-919-676-9515"] ["Office" "+1-919-676-9564"])
1357 ("6544 Battleford Drive")
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"))]
1367 (bbdb-vcard-import-test
1369 ** The other author of RFC 2426
1370 ------------------------------------------------------------
1374 ORG:Netscape Communications Corp.
1375 ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;
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
1384 "Netscape Communications Corp."
1385 (["Office" "+1-415-937-3419"]
1386 ["Office" "+1-415-528-4164"])
1388 ("501 E. Middlefield Rd.")
1393 ("howes@netscape.com")
1394 ((creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
1399 (bbdb-vcard-import-test
1401 ** vCard version 2.1 (coverted by convcard)
1402 ------------------------------------------------------------
1406 TEL;WORK;VOICE:+1-213-555-1234
1407 TEL;WORK;FAX:+1-213-555-5678
1413 (["Office" "+1-213-555-1234"]
1414 ["Office" "+1-213-555-5678"])
1417 ((creation-date .
"2010-03-04") (timestamp .
"2010-03-04"))]
1421 (bbdb-vcard-import-test
1423 ** vCard version 2.1 (coverted by convcard)
1424 ------------------------------------------------------------
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
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"))]
1448 (bbdb-vcard-import-test
1450 ** vCard version 2.1 (coverted by convcard)
1451 *** Quoted-printable
1452 ------------------------------------------------------------
1457 ORG:Doe Company, The;
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
1467 LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1234 North Street=0D=0AAnytown,
1468 TX 751234 =0D=0AUnited States of America
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
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
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"))]
1498 ;;;; The Export/Re-Import Tests
1499 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1502 (with-current-buffer "*BBDB
*"
1503 (bbdb-vcard-export "/tmp
/test-bbdb-0.vcf
" t nil))
1505 (let ((first-bbdb (bbdb-search (bbdb-records) ""))
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.