File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ #
3+ # phys_pkg.py
4+ #
5+ # Copyright (C) 2013 Steve Canny scanny@cisco.com
6+ #
7+ # This module is part of python-opc and is released under the MIT License:
8+ # http://www.opensource.org/licenses/mit-license.php
9+
10+ """
11+ Provides a general interface to a *physical* OPC package, such as a zip file.
12+ """
13+
14+
15+ class PhysPkgReader (object ):
16+ """
17+ Factory for physical package reader objects.
18+ """
19+ def __new__ (cls , pkg_file ):
20+ return ZipPkgReader (pkg_file )
21+
22+
23+ class ZipPkgReader (object ):
24+ """
25+ Implements |PhysPkgReader| interface for a zip file OPC package.
26+ """
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ #
3+ # test_phys_pkg.py
4+ #
5+ # Copyright (C) 2013 Steve Canny scanny@cisco.com
6+ #
7+ # This module is part of python-pptx and is released under the MIT License:
8+ # http://www.opensource.org/licenses/mit-license.php
9+
10+ """Test suite for opc.phys_pkg module."""
11+
12+ from opc .phys_pkg import PhysPkgReader
13+
14+ import pytest
15+
16+ from mock import Mock
17+
18+ from .unitutil import class_mock
19+
20+
21+ class DescribePhysPkgReader (object ):
22+
23+ @pytest .fixture
24+ def ZipPkgReader_ (self , request ):
25+ return class_mock ('opc.phys_pkg.ZipPkgReader' , request )
26+
27+ def it_constructs_a_pkg_reader_instance (self , ZipPkgReader_ ):
28+ # mockery ----------------------
29+ pkg_file = Mock (name = 'pkg_file' )
30+ # exercise ---------------------
31+ phys_pkg_reader = PhysPkgReader (pkg_file )
32+ # verify -----------------------
33+ ZipPkgReader_ .assert_called_once_with (pkg_file )
34+ assert phys_pkg_reader == ZipPkgReader_ .return_value
You can’t perform that action at this time.
0 commit comments