def test_complex_docprop_with_multiple_textnode_in_same_run_are_updated(self): document = Document(docx_path('two_textnodes_in_run_docproperty.docx')) paragraphs = xpath(document.element.body, '//w:p') assert 1 == len(paragraphs), 'input file contains one paragraph' assert 1 == len(xpath(document.element.body, '//w:instrText')), \ 'input contains one complex field docproperty' w_p = paragraphs[0] cached_values = cached_complex_field_values(w_p) assert 2 == len(cached_values), \ 'doc property value is scattered over 2 parts' assert 'Hello there' == ''.join(cached_values) CustomProperties(document).update_all() w_p = xpath(document.element.body, '//w:p')[0] cached_values = cached_complex_field_values(w_p) assert 1 == len(cached_values), \ 'doc property value has been reset to one cached value' assert 'i will be spllchecked!' == cached_values[0]
def test_complex_docprop_fields_with_multiple_textnodes_are_updated(self): document = Document(docx_path('spellchecked_docproperty.docx')) paragraphs = xpath(document.element.body, '//w:p') assert len(paragraphs) == 1, 'input file contains one paragraph' assert len(xpath(document.element.body, '//w:instrText')) == 1, \ 'input contains one complex field docproperty' w_p = paragraphs[0] cached_values = cached_complex_field_values(w_p) assert len(cached_values) == 4, \ 'doc property value is scattered over 4 parts' assert ''.join(cached_values) == 'i will be spllchecked!' CustomProperties(document).update_all() w_p = xpath(document.element.body, '//w:p')[0] cached_values = cached_complex_field_values(w_p) assert len(cached_values) == 1, \ 'doc property value has been reset to one cached value' assert cached_values[0] == 'i will be spllchecked!'