|
13 | 13 |
|
14 | 14 | from mock import Mock |
15 | 15 |
|
16 | | -from opc.package import OpcPackage |
| 16 | +from opc.package import OpcPackage, Unmarshaller |
17 | 17 |
|
18 | | -from .unitutil import class_mock |
| 18 | +from .unitutil import class_mock, method_mock |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class DescribeOpcPackage(object): |
@@ -44,3 +44,31 @@ def it_can_open_a_pkg_file(self, PackageReader_, PartFactory_, |
44 | 44 | Unmarshaller_.unmarshal.assert_called_once_with(pkg_reader, pkg, |
45 | 45 | PartFactory_) |
46 | 46 | assert isinstance(pkg, OpcPackage) |
| 47 | + |
| 48 | + |
| 49 | +class DescribeUnmarshaller(object): |
| 50 | + |
| 51 | + @pytest.fixture |
| 52 | + def _unmarshal_parts(self, request): |
| 53 | + return method_mock(Unmarshaller, '_unmarshal_parts', request) |
| 54 | + |
| 55 | + @pytest.fixture |
| 56 | + def _unmarshal_relationships(self, request): |
| 57 | + return method_mock(Unmarshaller, '_unmarshal_relationships', request) |
| 58 | + |
| 59 | + def it_can_unmarshal_from_a_pkg_reader(self, _unmarshal_parts, |
| 60 | + _unmarshal_relationships): |
| 61 | + # mockery ---------------------- |
| 62 | + pkg = Mock(name='pkg') |
| 63 | + pkg_reader = Mock(name='pkg_reader') |
| 64 | + part_factory = Mock(name='part_factory') |
| 65 | + parts = {1: Mock(name='part_1'), 2: Mock(name='part_2')} |
| 66 | + _unmarshal_parts.return_value = parts |
| 67 | + # exercise --------------------- |
| 68 | + Unmarshaller.unmarshal(pkg_reader, pkg, part_factory) |
| 69 | + # verify ----------------------- |
| 70 | + _unmarshal_parts.assert_called_once_with(pkg_reader, part_factory) |
| 71 | + _unmarshal_relationships.assert_called_once_with(pkg_reader, pkg, |
| 72 | + parts) |
| 73 | + for part in parts.values(): |
| 74 | + part._after_unmarshal.assert_called_once_with() |
0 commit comments