datetime_test.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # ical2vdir - convert .ics file to vdir directory
  2. #
  3. # Copyright (C) 2020 Fabian Peter Hammerle <fabian@hammerle.me>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. import datetime
  18. import pytest
  19. import ical2vdir
  20. _CEST = datetime.timezone(datetime.timedelta(hours=+2))
  21. @pytest.mark.parametrize(
  22. ("dt_obj", "expected_str"),
  23. [
  24. (datetime.datetime(2012, 7, 17, 12, 0, tzinfo=_CEST), "20120717T120000+0200"),
  25. (
  26. datetime.datetime(2012, 7, 17, 12, 0, tzinfo=datetime.timezone.utc),
  27. "20120717T120000+0000",
  28. ),
  29. ],
  30. )
  31. def test__datetime_basic_isoformat(
  32. dt_obj: datetime.datetime, expected_str: str
  33. ) -> None:
  34. # pylint: disable=protected-access
  35. assert ical2vdir._datetime_basic_isoformat(dt_obj) == expected_str