Skip to content

Commit

Permalink
Fixed style, added tests and changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
twissell- committed Aug 13, 2024
1 parent d4bcd67 commit b95a61a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This project should more or less adhere to [Semantic Versioning](https://semver.
* Use setuptools-scm / pyproject.toml (modern packaging). Details in https://github.com/python-caldav/caldav/pull/364 and https://github.com/python-caldav/caldav/pull/367
* Debugging tool - an environment variable can be set, causing the library to spew out server communications into files under /tmp. Details in https://github.com/python-caldav/caldav/pull/249 and https://github.com/python-caldav/caldav/issues/248
* Comaptibility matrix for posteo.de servers in `tests/compatibility_issues.py`
* Added sort_reverse option to the search function to reverse the sorting order of the found objects.

### Security

Expand Down
27 changes: 21 additions & 6 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ class hierarchy into a separate file)
import sys
import uuid
from collections import defaultdict
from datetime import date, datetime, timedelta, timezone
from typing import TYPE_CHECKING, Any, List, Optional, Set, Tuple, TypeVar, Union
from urllib.parse import ParseResult, SplitResult, quote, unquote
from datetime import date
from datetime import datetime
from datetime import timedelta
from datetime import timezone
from typing import Any
from typing import List
from typing import Optional
from typing import Set
from typing import Tuple
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union
from urllib.parse import ParseResult
from urllib.parse import quote
from urllib.parse import SplitResult
from urllib.parse import unquote

import icalendar
import vobject
Expand All @@ -22,10 +35,12 @@ class hierarchy into a separate file)
from lxml.etree import _Element
from vobject.base import VBase

from caldav.lib.python_utilities import to_normal_str, to_unicode, to_wire

from .elements.base import BaseElement
from .elements.cdav import CalendarData, CompFilter
from .elements.cdav import CalendarData
from .elements.cdav import CompFilter
from caldav.lib.python_utilities import to_normal_str
from caldav.lib.python_utilities import to_unicode
from caldav.lib.python_utilities import to_wire

try:
from typing import ClassVar, Optional, Union
Expand Down
10 changes: 8 additions & 2 deletions tests/test_caldav.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@
from caldav.objects import Todo

if test_xandikos:
from xandikos.web import XandikosBackend, XandikosApp
import asyncio

import aiohttp
import aiohttp.web
import asyncio
from xandikos.web import XandikosApp, XandikosBackend

if test_radicale:
import radicale.config
Expand Down Expand Up @@ -1332,6 +1333,11 @@ def testSearchEvent(self):
assert len(all_events) == 3
assert all_events[0].instance.vevent.summary.value == "Bastille Day Jitsi Party"

## Sorting in reverse order should work also
all_events = c.search(sort_keys=("SUMMARY", "DTSTAMP"), sort_reverse=True)
assert len(all_events) == 3
assert all_events[0].instance.vevent.summary.value == "Our Blissful Anniversary"

def testSearchSortTodo(self):
self.skip_on_compatibility_flag("read_only")
self.skip_on_compatibility_flag("no_todo")
Expand Down

0 comments on commit b95a61a

Please sign in to comment.