コード例 #1
0
def test_write_comments_vml():
    ws = _create_ws()[0]
    cw = CommentWriter(ws)
    reference_file = os.path.join(DATADIR, 'writer', 'expected',
                                  'commentsDrawing1.vml')
    content = cw.write_comments_vml()
    with open(reference_file) as expected:
        correct = fromstring(expected.read())
        check = fromstring(content)
        correct_ids = []
        correct_coords = []
        check_ids = []
        check_coords = []

        for i in correct.findall("{%s}shape" % vmlns):
            correct_ids.append(i.attrib["id"])
            row = i.find("{%s}ClientData" % excelns).find("{%s}Row" %
                                                          excelns).text
            col = i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                          excelns).text
            correct_coords.append((row, col))
            # blank the data we are checking separately
            i.attrib["id"] = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Row" %
                                                    excelns).text = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                    excelns).text = "0"

        for i in check.findall("{%s}shape" % vmlns):
            check_ids.append(i.attrib["id"])
            row = i.find("{%s}ClientData" % excelns).find("{%s}Row" %
                                                          excelns).text
            col = i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                          excelns).text
            check_coords.append((row, col))
            # blank the data we are checking separately
            i.attrib["id"] = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Row" %
                                                    excelns).text = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                    excelns).text = "0"

        assert set(correct_coords) == set(check_coords)
        assert set(correct_ids) == set(check_ids)
        diff = compare_xml(get_document_content(correct),
                           get_document_content(check))
        assert diff is None, diff
コード例 #2
0
def test_write_comments_vml(datadir):
    datadir.chdir()
    ws = _create_ws()[0]
    cw = CommentWriter(ws)
    content = cw.write_comments_vml()
    with open('commentsDrawing1.vml') as expected:
        correct = fromstring(expected.read())
    check = fromstring(content)
    correct_ids = []
    correct_coords = []
    check_ids = []
    check_coords = []

    for i in correct.findall("{%s}shape" % vmlns):
        correct_ids.append(i.attrib["id"])
        row = i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text
        col = i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                      excelns).text
        correct_coords.append((row, col))
        # blank the data we are checking separately
        i.attrib["id"] = "0"
        i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text = "0"
        i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                excelns).text = "0"

    for i in check.findall("{%s}shape" % vmlns):
        check_ids.append(i.attrib["id"])
        row = i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text
        col = i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                      excelns).text
        check_coords.append((row, col))
        # blank the data we are checking separately
        i.attrib["id"] = "0"
        i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text = "0"
        i.find("{%s}ClientData" % excelns).find("{%s}Column" %
                                                excelns).text = "0"

    assert set(correct_coords) == set(check_coords)
    assert set(correct_ids) == set(check_ids)
    diff = compare_xml(tostring(correct), tostring(check))
    assert diff is None, diff
コード例 #3
0
def test_write_comments_vml():
    ws = _create_ws()[0]
    cw = CommentWriter(ws)
    reference_file = os.path.join(DATADIR, 'writer', 'expected',
            'commentsDrawing1.vml')
    content = cw.write_comments_vml()
    with open(reference_file) as expected:
        correct = fromstring(expected.read())
        check = fromstring(content)
        correct_ids = []
        correct_coords = []
        check_ids = []
        check_coords = []

        for i in correct.findall("{%s}shape" % vmlns):
            correct_ids.append(i.attrib["id"])
            row = i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text
            col = i.find("{%s}ClientData" % excelns).find("{%s}Column" % excelns).text
            correct_coords.append((row,col))
            # blank the data we are checking separately
            i.attrib["id"] = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text="0"
            i.find("{%s}ClientData" % excelns).find("{%s}Column" % excelns).text="0"

        for i in check.findall("{%s}shape" % vmlns):
            check_ids.append(i.attrib["id"])
            row = i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text
            col = i.find("{%s}ClientData" % excelns).find("{%s}Column" % excelns).text
            check_coords.append((row,col))
            # blank the data we are checking separately
            i.attrib["id"] = "0"
            i.find("{%s}ClientData" % excelns).find("{%s}Row" % excelns).text="0"
            i.find("{%s}ClientData" % excelns).find("{%s}Column" % excelns).text="0"

        assert set(correct_coords) == set(check_coords)
        assert set(correct_ids) == set(check_ids)
        diff = compare_xml(get_document_content(correct), get_document_content(check))
        assert diff is None, diff