Skip to content

Commit 64932b0

Browse files
author
Steve Canny
committed
add ZipPkgWriter.__init__()
1 parent 9bb9e5f commit 64932b0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

opc/phys_pkg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Provides a general interface to a *physical* OPC package, such as a zip file.
1212
"""
1313

14-
from zipfile import ZipFile
14+
from zipfile import ZIP_DEFLATED, ZipFile
1515

1616

1717
class PhysPkgReader(object):
@@ -76,3 +76,6 @@ class ZipPkgWriter(object):
7676
"""
7777
Implements |PhysPkgWriter| interface for a zip file OPC package.
7878
"""
79+
def __init__(self, pkg_file):
80+
super(ZipPkgWriter, self).__init__()
81+
self._zipf = ZipFile(pkg_file, 'w', compression=ZIP_DEFLATED)

tests/test_phys_pkg.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212
import hashlib
1313

14+
from zipfile import ZIP_DEFLATED
15+
1416
from opc.packuri import PACKAGE_URI, PackURI
15-
from opc.phys_pkg import PhysPkgReader, PhysPkgWriter, ZipPkgReader
17+
from opc.phys_pkg import (
18+
PhysPkgReader, PhysPkgWriter, ZipPkgReader, ZipPkgWriter
19+
)
1620

1721
import pytest
1822

@@ -102,3 +106,12 @@ def it_returns_none_when_part_has_no_rels_xml(self, phys_reader):
102106
partname = PackURI('/ppt/viewProps.xml')
103107
rels_xml = phys_reader.rels_xml_for(partname)
104108
assert rels_xml is None
109+
110+
111+
class DescribeZipPkgWriter(object):
112+
113+
def it_opens_pkg_file_zip_on_construction(self, ZipFile_):
114+
pkg_file = Mock(name='pkg_file')
115+
ZipPkgWriter(pkg_file)
116+
ZipFile_.assert_called_once_with(pkg_file, 'w',
117+
compression=ZIP_DEFLATED)

0 commit comments

Comments
 (0)