tests: Add tests for BaseODS.add_annotation().

This commit is contained in:
Brett Smith 2021-03-10 10:25:19 -05:00
parent bf09cebf73
commit 1c71d7c6e1

View file

@ -782,3 +782,23 @@ def test_ods_writer_common_command(ods_writer):
ods_writer.set_common_properties(command=['testcmd', 'testarg*'])
cmd_prop = get_child(ods_writer.document.meta, odf.meta.UserDefined, name='ReportCommand')
assert cmd_prop.text == 'testcmd \'testarg*\''
@pytest.mark.parametrize('text,when,parent', itertools.product(
[None, 'comment text'],
[None, datetime.datetime.now()],
[True, False],
))
def test_ods_add_annotation(ods_writer, text, when, parent):
start_time = datetime.datetime.now()
parent = odf.table.TableCell() if parent else None
actual = ods_writer.add_annotation(text, when, parent)
if text is None:
assert actual.firstChild is actual.lastChild
else:
assert actual.lastChild.text == text
if when is None:
assert actual.firstChild.text >= start_time.isoformat(timespec='seconds')
else:
assert actual.firstChild.text == when.isoformat(timespec='seconds')
if parent is not None:
assert parent.lastChild is actual