Example #1
0
 def open(cls, pkg_file):
     """
     Return an |OpcPackage| instance loaded with the contents of
     *pkg_file*.
     """
     pkg_reader = PackageReader.from_file(pkg_file)
     package = cls()
     Unmarshaller.unmarshal(pkg_reader, package, PartFactory)
     return package
Example #2
0
 def open(cls, pkg_file):
     """
     Return an |OpcPackage| instance loaded with the contents of
     *pkg_file*.
     """
     pkg_reader = PackageReader.from_file(pkg_file)
     package = cls()
     Unmarshaller.unmarshal(pkg_reader, package, PartFactory)
     return package
    def it_can_construct_from_pkg_file(self, _init_, PhysPkgReader_, from_xml,
                                       _srels_for, _load_serialized_parts):
        phys_reader = PhysPkgReader_.return_value
        content_types = from_xml.return_value
        pkg_srels = _srels_for.return_value
        sparts = _load_serialized_parts.return_value
        pkg_file = Mock(name='pkg_file')

        pkg_reader = PackageReader.from_file(pkg_file)

        PhysPkgReader_.assert_called_once_with(pkg_file)
        from_xml.assert_called_once_with(phys_reader.content_types_xml)
        _srels_for.assert_called_once_with(phys_reader, '/')
        _load_serialized_parts.assert_called_once_with(phys_reader, pkg_srels,
                                                       content_types)
        phys_reader.close.assert_called_once_with()
        _init_.assert_called_once_with(ANY, content_types, pkg_srels, sparts)
        assert isinstance(pkg_reader, PackageReader)
 def it_can_construct_from_pkg_file(
         self, init, PhysPkgReader_, from_xml, _srels_for,
         _load_serialized_parts):
     # mockery ----------------------
     phys_reader = PhysPkgReader_.return_value
     content_types = from_xml.return_value
     pkg_srels = _srels_for.return_value
     sparts = _load_serialized_parts.return_value
     pkg_file = Mock(name='pkg_file')
     # exercise ---------------------
     pkg_reader = PackageReader.from_file(pkg_file)
     # verify -----------------------
     PhysPkgReader_.assert_called_once_with(pkg_file)
     from_xml.assert_called_once_with(phys_reader.content_types_xml)
     _srels_for.assert_called_once_with(phys_reader, '/')
     _load_serialized_parts.assert_called_once_with(phys_reader, pkg_srels,
                                                    content_types)
     phys_reader.close.assert_called_once_with()
     init.assert_called_once_with(content_types, pkg_srels, sparts)
     assert isinstance(pkg_reader, PackageReader)