Skip to content

Commit 77722ed

Browse files
committed
a bit more work on this
1 parent 9d5d3bf commit 77722ed

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

tests/test_caldav.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ def testSearchSortTodo(self):
17091709
dtstart=date(2022, 10, 11),
17101710
uid="test1",
17111711
)
1712-
assert(t1.is_pending())
1712+
assert t1.is_pending()
17131713
t2 = c.save_todo(
17141714
summary="2 task future",
17151715
due=datetime.now() + timedelta(hours=15),
@@ -1732,7 +1732,7 @@ def testSearchSortTodo(self):
17321732
status="COMPLETED",
17331733
uid="test5",
17341734
)
1735-
assert(not t5.is_pending())
1735+
assert not t5.is_pending()
17361736
t6 = c.save_todo(
17371737
summary="6 task has categories",
17381738
categories="home,garden,sunshine",
@@ -1852,11 +1852,11 @@ def testSearchTodos(self):
18521852
assert len(some_todos) - pre_cnt == 6
18531853

18541854
## completing events, and it should not show up anymore
1855-
assert(t3.is_pending())
1855+
assert t3.is_pending()
18561856
t3.complete()
18571857
t5.complete()
18581858
t6.complete()
1859-
assert(not t3.is_pending())
1859+
assert not t3.is_pending()
18601860

18611861
some_todos = c.search(todo=True)
18621862
assert len(some_todos) == 3 + pre_cnt
@@ -1866,14 +1866,14 @@ def testSearchTodos(self):
18661866
assert len(all_todos) == 6 + pre_cnt
18671867

18681868
## Just for increasing code coverage
1869-
t3.component.pop('COMPLETED')
1870-
assert(not t3.is_pending())
1869+
t3.component.pop("COMPLETED")
1870+
assert not t3.is_pending()
18711871

18721872
## Test that uncomplete works
18731873
t5.uncomplete()
18741874
some_todos = c.search(todo=True)
18751875
assert len(some_todos) == 4 + pre_cnt
1876-
1876+
18771877
def testWrongPassword(self):
18781878
if (
18791879
not "password" in self.server_params
@@ -2002,16 +2002,24 @@ def testCreateChildParent(self):
20022002
assert len(foo) == 0
20032003
assert len(bar) == 0
20042004

2005-
another_parent.set_relation('ctuid4', reltype="CHILD")
2005+
another_parent.set_relation("ctuid4", reltype="CHILD")
20062006
another_parent.load()
20072007
another_child.load()
20082008
assert another_child.check_reverse_relations() == []
20092009
assert another_parent.check_reverse_relations() == []
20102010
foo = another_parent.get_relatives(reltypes={"CHILD", "PARENT"})
20112011
bar = another_child.get_relatives(reltypes={"CHILD", "PARENT"})
2012-
assert sum([len(x.get('CHILD', set())) + len(x.get('PARENT', set())) for x in [foo, bar]]) == 2
2013-
assert [str(obj.component['UID']) for obj in foo['CHILD']] == ['ctuid4']
2014-
assert [str(obj.component['UID']) for obj in bar['PARENT']] == ['ctuid5']
2012+
assert (
2013+
sum(
2014+
[
2015+
len(x.get("CHILD", set())) + len(x.get("PARENT", set()))
2016+
for x in [foo, bar]
2017+
]
2018+
)
2019+
== 2
2020+
)
2021+
assert [str(obj.component["UID"]) for obj in foo["CHILD"]] == ["ctuid4"]
2022+
assert [str(obj.component["UID"]) for obj in bar["PARENT"]] == ["ctuid5"]
20152023

20162024
def testSetDue(self):
20172025
self.skip_on_compatibility_flag("read_only")
@@ -2102,6 +2110,17 @@ def testSetDue(self):
21022110
check_dependent=True,
21032111
)
21042112

2113+
## `todo.set_due` with `check_dependent='return'`
2114+
## should return the parent
2115+
assert (
2116+
parent.component["uid"]
2117+
== some_todo.set_due(
2118+
datetime(2022, 12, 26, 21, 30, tzinfo=utc),
2119+
move_dtstart=True,
2120+
check_dependent="return",
2121+
).component["uid"]
2122+
)
2123+
21052124
child = c.save_todo(
21062125
dtstart=datetime(2022, 12, 26, 19, 45),
21072126
due=datetime(2022, 12, 26, 19, 55),

0 commit comments

Comments
 (0)