tests: Add tests for BaseODS.add_annotation().
This commit is contained in:
parent
bf09cebf73
commit
1c71d7c6e1
1 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue