From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Reindert-Jan Ekker Newsgroups: gmane.emacs.bugs Subject: bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty Date: Fri, 16 Jun 2023 20:45:48 +0200 Message-ID: References: <87jzw8hcrp.fsf@gmail.com> <87bkhjhc3v.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35703"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.3; emacs 29.0.90 Cc: 64023@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 17 10:23:30 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qARDV-00096H-Fg for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Jun 2023 10:23:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qARDD-0001yS-IO; Sat, 17 Jun 2023 04:23:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qARD9-0001y8-QS for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 04:23:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qARD9-0007Wj-HS for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 04:23:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qARD9-0000Me-AJ for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 04:23:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Reindert-Jan Ekker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 08:23:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64023 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 64023-submit@debbugs.gnu.org id=B64023.16869901371277 (code B ref 64023); Sat, 17 Jun 2023 08:23:07 +0000 Original-Received: (at 64023) by debbugs.gnu.org; 17 Jun 2023 08:22:17 +0000 Original-Received: from localhost ([127.0.0.1]:50831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qARCJ-0000KU-Gb for submit@debbugs.gnu.org; Sat, 17 Jun 2023 04:22:17 -0400 Original-Received: from outbound5.mail.transip.nl ([136.144.136.9]:33486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAEX3-0001Sp-Ic for 64023@debbugs.gnu.org; Fri, 16 Jun 2023 14:50:52 -0400 Original-Received: from submission6.mail.transip.nl (unknown [10.103.8.157]) by outbound5.mail.transip.nl (Postfix) with ESMTP id 4QjSsg2XP7zHNBn; Fri, 16 Jun 2023 20:50:47 +0200 (CEST) Original-Received: from www.codesensei.nl (unknown [IPv6:2a01:7c8:bb02:73:5054:ff:fe0b:4b1]) by submission6.mail.transip.nl (Postfix) with ESMTPSA id 4QjSsf1WC7z12LWg; Fri, 16 Jun 2023 20:50:46 +0200 (CEST) Original-Received: from [24.132.50.73] (helo=CodeSensei-MacBook-Air.local) by www.codesensei.nl with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qAEr2-0004Ud-3H; Fri, 16 Jun 2023 21:11:28 +0200 In-reply-to: <87bkhjhc3v.fsf@gmail.com> X-Scanned-By: ClueGetter at submission6.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=codesensei.nl; t=1686941446; h=from:subject:to:cc: references:in-reply-to:date:mime-version:content-type; bh=0cIuziEpDGI+ew1RYsR/SmCMIEUUhtcKBFXAc0ISCnY=; b=ThS6KhabmjO48a0EV1poTtCZY8Fk64gGzRSG5AF5HpbYQ4S/YAnt4JwUJSrN7DtMNiQwz6 uqY/heF9qOGdLYb4GwEpVXB7GYLt3TASs0M8PtYvIDsqxVxVcHSYwKQZLXJlbL6Zs1A1MV huLldaGVHCYGCrgrFlESQnrSU/2nPBb30J50nb1Z9P6gdlE7dTy24hmGec/vGGzcQEojUe NtttT8Nj2ef4aRx2bIjahG9M/kBH3AK+g3g9VIHtXw2hyZnRF5oOLrhTlQIyDs7MhwZEGP g2SVuNdXm4xLc/QK5RxrEeZs1uzb0y0T///bVSmFT1niEZ7jWhmTbB3Lepxc6g== X-Report-Abuse-To: abuse@transip.nl X-Mailman-Approved-At: Sat, 17 Jun 2023 04:22:13 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263513 Archived-At: --=-=-= Content-Type: text/plain As a little exercise I've been writing some unit tests for the bug you fixed regarding updates to events with empty description. Patch is attached. Looking forward to any feedback. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-test-lisp-gnus-gnus-icalendar-tests.el-Add-tests-for.patch Content-Description: Patch: unit tests >From 67859adc32616c2251f507b89010968cc9246034 Mon Sep 17 00:00:00 2001 From: reindert Date: Fri, 16 Jun 2023 20:39:00 +0200 Subject: [PATCH] ; * test/lisp/gnus/gnus-icalendar-tests.el: Add tests for Bug#64023 --- test/lisp/gnus/gnus-icalendar-tests.el | 167 +++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/test/lisp/gnus/gnus-icalendar-tests.el b/test/lisp/gnus/gnus-icalendar-tests.el index 8f89e8f..aab9a88 100644 --- a/test/lisp/gnus/gnus-icalendar-tests.el +++ b/test/lisp/gnus/gnus-icalendar-tests.el @@ -27,6 +27,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'gnus-icalendar) @@ -255,5 +256,171 @@ gnus-icalendary-weekly-byday <2020-09-21 14:00-14:30 +1w>"))) (setenv "TZ" tz)))) + +(ert-deftest gnus-icalendar-org-entry-from-ics () + "Test creation of org mode entry from ics string." + ;; Use this form so as not to rely on system tz database. + ;; Eg hydra.nixos.org. + (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") + (let ((event (gnus-icalendar-tests--get-ical-event "BEGIN:VCALENDAR +PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN +VERSION:2.0 +METHOD:REQUEST +BEGIN:VEVENT +UID:5e61e65c-c991-4e42-bd41-44fcf057ea11 +SUMMARY:test appointment +ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com +ATTENDEE;CN=Me;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:me@example.com +ATTENDEE;CN=Myself;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:myself@example.com +DTSTART;TZID=Europe/Brussels:20230811T160000 +DTEND;TZID=Europe/Brussels:20230811T170000 +DESCRIPTION;ALTREP=\"data:text/html,%3Cbody%3ELet's%20code%3C%2Fbody%3E\":Let's code +LOCATION:At home +END:VEVENT +END:VCALENDAR"))) + (should (string= (substring-no-properties (gnus-icalendar-event->org-entry event nil)) + "* test appointment (At home) +:PROPERTIES: +:ICAL_EVENT: t +:ID: 5e61e65c-c991-4e42-bd41-44fcf057ea11 +:ORGANIZER: info@example.com +:LOCATION: At home +:PARTICIPATION_TYPE: non-participant +:REQ_PARTICIPANTS: Me, Myself +:OPT_PARTICIPANTS: +:RRULE: +:REPLY: Not replied yet +:END: + + <2023-08-11 16:00-17:00> + + Let's code")))) + + +(ert-deftest gnus-icalendar-org-entry-from-ics-no-loc-no-desc () + "Test creation of org mode entry from ics string, no location, no description." + ;; Use this form so as not to rely on system tz database. + ;; Eg hydra.nixos.org. + (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") + (let ((event (gnus-icalendar-tests--get-ical-event "BEGIN:VCALENDAR +PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN +VERSION:2.0 +METHOD:REQUEST +BEGIN:VEVENT +UID:5e61e65c-c991-4e42-bd41-44fcf057ea11 +SUMMARY:test appointment +ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com +ATTENDEE;CN=Me;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:me@example.com +ATTENDEE;CN=Myself;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:myself@example.com +DTSTART;TZID=Europe/Brussels:20230811T160000 +DTEND;TZID=Europe/Brussels:20230811T170000 +END:VEVENT +END:VCALENDAR"))) + (should (string= (substring-no-properties (gnus-icalendar-event->org-entry event nil)) + "* test appointment +:PROPERTIES: +:ICAL_EVENT: t +:ID: 5e61e65c-c991-4e42-bd41-44fcf057ea11 +:ORGANIZER: info@example.com +:LOCATION: +:PARTICIPATION_TYPE: non-participant +:REQ_PARTICIPANTS: Me, Myself +:OPT_PARTICIPANTS: +:RRULE: +:REPLY: Not replied yet +:END: + + <2023-08-11 16:00-17:00> + + No description")))) + + +(defconst gnus-icalendar-tests--org-entry-no-desc + "* Org entry with empty description +:PROPERTIES: +:ICAL_EVENT: t +:ID: xxx-11-yyy +:ORGANIZER: No idea +:LOCATION: Nowhere +:PARTICIPATION_TYPE: non-participant +:REQ_PARTICIPANTS: +:OPT_PARTICIPANTS: +:RRULE: +:REPLY: Not replied yet +:END: + + <2023-01-01 13:00-14:00>") + + +(defun gnus-icalender-tests--get-updated-event (description) + "Create updated event with DESCRIPTION and new date 2024-01-01. + +If DESCRIPTION is nil, we don't add a description line at all." + ;; Use this form so as not to rely on system tz database. + ;; Eg hydra.nixos.org. + (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") + (let ((description (if description (format "DESCRIPTION:%s\n" description) ""))) + (gnus-icalendar-tests--get-ical-event (format "BEGIN:VCALENDAR +METHOD:REQUEST +BEGIN:VEVENT +UID:xxx-11-yyy +SUMMARY:Updated event +ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com +DTSTART;TZID=Europe/Brussels:20240101T180000 +DTEND;TZID=Europe/Brussels:20240101T190000 +%s +LOCATION:unknown +END:VEVENT +END:VCALENDAR" description)))) + + +(ert-deftest gnus-icalendar-update-org-event-no-description-add () + "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 . + +Update an existing org event that has no description; add description. +Check timestamp has changed." + (ert-with-temp-file + calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc + (gnus-icalendar--update-org-event (gnus-icalender-tests--get-updated-event "New description") + 'accepted `(,calendar-file)) + (with-current-buffer (find-buffer-visiting calendar-file) + (let ((new-entry (buffer-substring-no-properties (point-min) (point-max)))) + (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry)) + (should (string-match-p (regexp-quote "New description") new-entry)) + (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry)) + (should-not (string-match-p (regexp-quote "No description") new-entry)))))) + + +(ert-deftest gnus-icalendar-update-org-event-keep-no-description () + "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 . + +Update an existing org event that has no description; keep it empty. +Check timestamp has changed." + (ert-with-temp-file + calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc + (let ((event (gnus-icalender-tests--get-updated-event nil))) + (gnus-icalendar--update-org-event event 'accepted `(,calendar-file)) + (with-current-buffer (find-buffer-visiting calendar-file) + (let ((new-entry (buffer-substring-no-properties (point-min) (point-max)))) + (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry)) + (should (string-match-p (regexp-quote "No description") new-entry)) + (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry))))))) + + +(ert-deftest gnus-icalendar-update-org-event-remove-description () + "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 . + +Update an existing org event that has a description; set description empty." + (ert-with-temp-file + calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc + (let ((event (gnus-icalender-tests--get-updated-event nil))) + (oset event :description nil) + (gnus-icalendar--update-org-event event'accepted `(,calendar-file)) + (with-current-buffer (find-buffer-visiting calendar-file) + (let ((new-entry (buffer-substring-no-properties (point-min) (point-max)))) + (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry)) + (should (string-match-p (regexp-quote "No description") new-entry)) + (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry))))))) + (provide 'gnus-icalendar-tests) ;;; gnus-icalendar-tests.el ends here -- 2.40.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Robert Pluim writes: > (please keep the bug address in CC) > >>>>>> On Mon, 12 Jun 2023 20:16:30 +0200, Reindert-Jan Ekker said: > > Reindert-Jan> Yes, that works! > > OK. Eli, emacs-29 or master? It=CA=BCs a pretty small change, but it=CA= =BCs not > a regression as such. > > Reindert-Jan> By the way, what is the intended behaviour of > Reindert-Jan> gnus-icalendar--cancel-org-event? It seems to search fo= r a property "DT" > Reindert-Jan> that does not exist (at least in my files), so it does = not change the > Reindert-Jan> event. Is this a bug or am I missing some configuration= somewhere? > > It looks like a bug. I can=CA=BCt find any code creating such a property, > the current code inserts the timestamp in the body of the org entry. > > Robert --=20 Reindert-Jan Ekker Code Sensei --=-=-=--