def when_optional_attributes_of_comment_are_not_blank_then_they_are_read():
    comments = create_comments_reader(body_xml.reader())(xml_element("w:comments", {}, [
        xml_element("w:comment", {"w:id": "1", "w:author": "The Piemaker", "w:initials": "TP"}, []),
    ]))
    comment, = comments.value
    assert_equal("The Piemaker", comment.author_name)
    assert_equal("TP", comment.author_initials)
def when_optional_attributes_of_comment_are_missing_then_they_are_as_none():
    comments = create_comments_reader(body_xml.reader())(xml_element("w:comments", {}, [
        xml_element("w:comment", {"w:id": "1"}, []),
    ]))
    comment, = comments.value
    assert_equal(None, comment.author_name)
    assert_equal(None, comment.author_initials)
def _read_and_get_document_xml_element(*args, **kwargs):
    body_reader = body_xml.reader()
    result = read_document_xml_element(*args,
                                       body_reader=body_reader,
                                       **kwargs)
    assert_equal([], result.messages)
    return result.value
def id_and_body_of_comment_is_read():
    body = [xml_element("w:p")]
    comments = create_comments_reader(body_xml.reader())(xml_element("w:comments", {}, [
        xml_element("w:comment", {"w:id": "1"}, body),
    ]))
    assert_equal(1, len(comments.value))
    assert_equal(comments.value[0].body, [documents.paragraph(children=[])])
    assert_equal("1", comments.value[0].comment_id)
def id_and_body_of_footnote_are_read():
    footnote_body = [xml_element("w:p")]
    footnotes = read_footnotes_xml_element(xml_element("w:footnotes", {}, [
        xml_element("w:footnote", {"w:id": "1"}, footnote_body),
    ]), body_reader=body_xml.reader())
    assert_equal(1, len(footnotes.value))
    assert isinstance(footnotes.value[0].body[0], documents.Paragraph)
    assert_equal("1", footnotes.value[0].note_id)
Exemple #6
0
def id_and_body_of_comment_is_read():
    body = [xml_element("w:p")]
    comments = create_comments_reader(body_xml.reader())(xml_element(
        "w:comments", {}, [
            xml_element("w:comment", {"w:id": "1"}, body),
        ]))
    assert_equal(1, len(comments.value))
    assert_equal(comments.value[0].body, [documents.paragraph(children=[])])
    assert_equal("1", comments.value[0].comment_id)
Exemple #7
0
def when_optional_attributes_of_comment_are_missing_then_they_are_read_as_none(
):
    comments = create_comments_reader(body_xml.reader())(xml_element(
        "w:comments", {}, [
            xml_element("w:comment", {"w:id": "1"}, []),
        ]))
    comment, = comments.value
    assert_equal(None, comment.author_name)
    assert_equal(None, comment.author_initials)
Exemple #8
0
def id_and_body_of_footnote_are_read():
    footnote_body = [xml_element("w:p")]
    footnotes = create_footnotes_reader(body_xml.reader())(xml_element(
        "w:footnotes", {}, [
            xml_element("w:footnote", {"w:id": "1"}, footnote_body),
        ]))
    assert_equal(1, len(footnotes.value))
    assert isinstance(footnotes.value[0].body[0], documents.Paragraph)
    assert_equal("1", footnotes.value[0].note_id)
Exemple #9
0
def when_optional_attributes_of_comment_are_not_blank_then_they_are_read():
    comments = create_comments_reader(body_xml.reader())(xml_element(
        "w:comments", {}, [
            xml_element("w:comment", {
                "w:id": "1",
                "w:author": "The Piemaker",
                "w:initials": "TP"
            }, []),
        ]))
    comment, = comments.value
    assert_equal("The Piemaker", comment.author_name)
    assert_equal("TP", comment.author_initials)
Exemple #10
0
def when_optional_attributes_of_comment_are_blank_then_they_are_read_as_none():
    comments = read_comments_xml_element(xml_element("w:comments", {}, [
        xml_element("w:comment", {
            "w:id": "1",
            "w:author": " ",
            "w:initials": " "
        }, []),
    ]),
                                         body_reader=body_xml.reader())
    comment, = comments.value
    assert_equal(None, comment.author_name)
    assert_equal(None, comment.author_initials)
def _read_document_xml_element(element, *args, **kwargs):
    reader = body_xml.reader(*args, **kwargs)
    return reader.read(element)
Exemple #12
0
def _read_document_xml(func, element, *args, **kwargs):
    reader = body_xml.reader(*args, **kwargs)
    return func(reader, element)
def _read_document_xml(func, element, *args, **kwargs):
    reader = body_xml.reader(*args, **kwargs)
    return func(reader, element)
def _read_and_get_document_xml_element(*args, **kwargs):
    body_reader = body_xml.reader()
    result = read_document_xml_element(*args, body_reader=body_reader, **kwargs)
    assert_equal([], result.messages)
    return result.value