/usr/lib/python2.7/dist-packages/openpyxl/chartsheet/tests/test_publish.py is in python-openpyxl 2.4.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
import pytest
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def WebPublishItem():
from ..publish import WebPublishItem
return WebPublishItem
class TestWebPulishItem:
def test_read(self, WebPublishItem):
src = """
<webPublishItem id="6433" divId="Views_6433" sourceType="chart" sourceRef=""
sourceObject="Chart 1" destinationFile="D:\Publish.mht" autoRepublish="0"/>
"""
xml = fromstring(src)
webPulishItem = WebPublishItem.from_tree(xml)
assert webPulishItem.id == 6433
assert webPulishItem.sourceObject == "Chart 1"
def test_write(self, WebPublishItem):
webPublish = WebPublishItem(id=6433, divId="Views_6433", sourceType="chart", sourceRef="",
sourceObject="Chart 1", destinationFile="D:\Publish.mht", title="First Chart",
autoRepublish=False)
expected = """
<webPublishItem id="6433" divId="Views_6433" sourceType="chart" sourceRef=""
sourceObject="Chart 1" destinationFile="D:\Publish.mht" title="First Chart" autoRepublish="0"/>
"""
xml = tostring(webPublish.to_tree())
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def WebPublishItems():
from ..publish import WebPublishItems
return WebPublishItems
class TestWebPublishItems:
def test_read(self, WebPublishItems):
src = """
<webPublishItems count="1">
<webPublishItem id="6433" divId="Views_6433" sourceType="chart" sourceRef=""
sourceObject="Chart 1" destinationFile="D:\Publish.mht" autoRepublish="0"/>
</webPublishItems>
"""
xml = fromstring(src)
webPublishItems = WebPublishItems.from_tree(xml)
assert webPublishItems.count == 1
assert webPublishItems.webPublishItem[0].sourceObject == "Chart 1"
def test_write(self, WebPublishItems):
from ..publish import WebPublishItem
webPublish_6433 = WebPublishItem(id=6433, divId="Views_6433", sourceType="chart", sourceRef="",
sourceObject="Chart 1", destinationFile="D:\Publish.mht", title="First Chart",
autoRepublish=False)
webPublish_64487 = WebPublishItem(id=64487, divId="Views_64487", sourceType="chart", sourceRef="Ref_545421",
sourceObject="Chart 15", destinationFile="D:\Publish_12.mht",
title="Second Chart",
autoRepublish=True)
webPublishItems = WebPublishItems(webPublishItem=[webPublish_6433, webPublish_64487])
expected = """
<WebPublishItems count="2">
<webPublishItem id="6433" divId="Views_6433" sourceType="chart" sourceRef=""
sourceObject="Chart 1" destinationFile="D:\Publish.mht" title="First Chart" autoRepublish="0"/>
<webPublishItem id="64487" divId="Views_64487" sourceType="chart" sourceRef="Ref_545421"
sourceObject="Chart 15" destinationFile="D:\Publish_12.mht" title="Second Chart" autoRepublish="1"/>
</WebPublishItems>
"""
xml = tostring(webPublishItems.to_tree())
diff = compare_xml(xml, expected)
assert diff is None, diff
|