Changeset - 1c71d7c6e145
[Not reviewed]
0 1 0
Brett Smith - 3 years ago 2021-03-10 15:25:19
brettcsmith@brettcsmith.org
tests: Add tests for BaseODS.add_annotation().
1 file changed with 20 insertions and 0 deletions:
0 comments (0 inline, 0 general)
tests/test_reports_spreadsheet.py
Show inline comments
...
 
@@ -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
0 comments (0 inline, 0 general)