/usr/lib/python2.7/dist-packages/openpyxl/packaging/tests/test_core.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 82 83 84 | from __future__ import absolute_import
# copyright openpyxl 2014
import datetime
import pytest
from openpyxl.tests.helper import compare_xml
from openpyxl.xml.functions import fromstring, tostring
@pytest.fixture()
def SampleProperties():
from .. core import DocumentProperties
props = DocumentProperties()
props.keywords = "one, two, three"
props.created = datetime.datetime(2010, 4, 1, 20, 30, 00)
props.modified = datetime.datetime(2010, 4, 5, 14, 5, 30)
props.lastPrinted = datetime.datetime(2014, 10, 14, 10, 30)
props.category = "The category"
props.contentStatus = "The status"
props.creator = 'TEST_USER'
props.lastModifiedBy = "SOMEBODY"
props.revision = "0"
props.version = "2.5"
props.description = "The description"
props.identifier = "The identifier"
props.language = "The language"
props.subject = "The subject"
props.title = "The title"
return props
def test_ctor(SampleProperties):
expected = """
<coreProperties
xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:creator>TEST_USER</dc:creator>
<dc:title>The title</dc:title>
<dc:description>The description</dc:description>
<dc:subject>The subject</dc:subject>
<dc:identifier>The identifier</dc:identifier>
<dc:language>The language</dc:language>
<dcterms:created xsi:type="dcterms:W3CDTF">2010-04-01T20:30:00Z</dcterms:created>
<dcterms:modified xsi:type="dcterms:W3CDTF">2010-04-05T14:05:30Z</dcterms:modified>
<lastModifiedBy>SOMEBODY</lastModifiedBy>
<category>The category</category>
<contentStatus>The status</contentStatus>
<version>2.5</version>
<revision>0</revision>
<keywords>one, two, three</keywords>
<lastPrinted>2014-10-14T10:30:00Z</lastPrinted>
</coreProperties>
"""
xml = tostring(SampleProperties.to_tree())
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_tree(datadir, SampleProperties):
datadir.chdir()
with open("core.xml") as src:
content = src.read()
content = fromstring(content)
props = SampleProperties.from_tree(content)
assert props == SampleProperties
def test_qualified_datetime():
from ..core import QualifiedDateTime
dt = QualifiedDateTime()
tree = dt.to_tree("time", datetime.datetime(2015, 7, 20, 12, 30))
xml = tostring(tree)
expected = """
<time xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="dcterms:W3CDTF">
2015-07-20T12:30:00Z
</time>"""
diff = compare_xml(xml, expected)
assert diff is None, diff
|