bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34315: [PATCH] icalendar.el: DURATION fix + more robust timezone han


From: Thomas Plass
Subject: bug#34315: [PATCH] icalendar.el: DURATION fix + more robust timezone handling
Date: Thu, 1 Oct 2020 21:49:06 +0300

I'd like to get some guidance from people involved on the following proposal:

Ulf Jasper wrote at 18:54 on October 1, 2020:

: Currently there is no way to use ics files in icalendar-tests.

Would it be acceptable to:

  - create a directory root/test/lisp/calendar/icalendar-resources

  - extend icalendar-tests.el with the following:

    (defvar icalendar-resources-directory "icalendar-resources"
      "Name of directory containing ICS files.
    This directory is relative to icalendar-tests.el.")
    
    (defun icalendar-tests--get-ical-from-file (ics-file &optional component)
      "Return iCalendar data structures from ICS-FILE.
    Optional symbol COMPONENT names a top-level component like 'VTIMEZONE."
      (let (ical)
        (if (file-exists-p ics-file)
            (save-excursion
              (with-temp-buffer
                (insert-file-contents ics-file)
                (goto-char (point-min))
                (setq ical (car (icalendar--read-element nil nil)))
                (if component
                    (setq res (car (icalendar--get-children ical component)))
                  (setq res ical))))
          (error "Can't find ICS file %s" ics-file))))


Which could be used thusly in the definition of 'icalendar--parse-vtimezone:

(ert-deftest icalendar--parse-vtimezone ()
  "Test method for `icalendar--parse-vtimezone'."
  (let (vtimezone result)

    (setq vtimezone (icalendar-tests--get-ical-from-file
                     (concat (file-name-as-directory 
icalendar-resources-directory)
                             
"Asia_Shanghai_20200916T070000_in-calendar_VTIMEZONE_tzurl_org.ics")
                     'VTIMEZONE))
    (setq result (icalendar--parse-vtimezone vtimezone))
    (should (string= "Asia/Shanghai" (car result)))
    (message (cdr result))
    (should (string= "STD-08:00"
                        (cdr result)))     


  ...
  ))


I have no idea how the test code is run, in particular how

  (concat (file-name-as-directory icalendar-resources-directory)
          "Asia_Shanghai_20200916T070000_in-calendar_VTIMEZONE_tzurl_org.ics")

could be made to resolve.

Also, I cannot alter the git.

Please advise.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]