@@ -29,12 +29,13 @@ import odf.table
import odf.text
from decimal import Decimal
from . import testutil
from conservancy_beancount import rtutil
from conservancy_beancount.reports import core
EN_US = babel.core.Locale('en', 'US')
XML_NAMES_LIST = [None, 'ce2', 'xml_testname']
XML_NAMES = itertools.cycle(XML_NAMES_LIST)
@@ -490,12 +491,47 @@ def test_ods_writer_float_cell(ods_writer, cell_source, style_name):
assert cell.getAttribute('valuetype') == 'float'
assert cell.getAttribute('stylename') == style_name
expected = str(cell_source)
assert cell.getAttribute('value') == expected
assert get_text(cell) == expected
def test_ods_writer_meta_links_cell(ods_writer):
rt_client = testutil.RTClient()
ods_writer.rt_wrapper = rtutil.RT(rt_client)
rt_url = rt_client.DEFAULT_URL[:-10]
meta_links = [
'rt://ticket/1',
'rt://ticket/2/attachments/9',
'rt:1/5',
'Invoices/0123.pdf',
]
cell = ods_writer.meta_links_cell(meta_links, stylename='meta1')
assert cell.getAttribute('valuetype') == 'string'
assert cell.getAttribute('stylename') == 'meta1'
children = iter(get_children(cell, odf.text.A))
child = next(children)
assert child.getAttribute('type') == 'simple'
expect_url = f'{rt_url}/Ticket/Display.html?id=1'
assert child.getAttribute('href') == expect_url
assert get_text(child) == 'rt:1'
expect_url = f'{rt_url}/Ticket/Display.html?id=2#txn-7'
assert get_text(child) == 'rt:2/9'
expect_url = f'{rt_url}/Ticket/Attachment/1/5/photo.jpg'
assert get_text(child) == 'photo.jpg'
expect_url = f'../{meta_links[3]}'
assert get_text(child) == '0123.pdf'
def test_ods_writer_multiline_cell(ods_writer):
cell = ods_writer.multiline_cell(iter(STRING_CELL_DATA))
children = get_children(cell, odf.text.P)
for expected, child in itertools.zip_longest(STRING_CELL_DATA, children):
assert get_text(child) == expected