Skip to content

Commit db1c1cb

Browse files
author
Steve Canny
committed
add RelationshipCollection.__len__()
1 parent c10df00 commit db1c1cb

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

opc/package.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class RelationshipCollection(object):
105105
"""
106106
def __init__(self, baseURI):
107107
super(RelationshipCollection, self).__init__()
108+
self._rels = []
109+
110+
def __len__(self):
111+
"""Implements len() built-in on this object"""
112+
return self._rels.__len__()
108113

109114

110115
class Unmarshaller(object):

tests/test_package.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
from mock import call, Mock
1515

16-
from opc.package import OpcPackage, Part, PartFactory, Unmarshaller
16+
from opc.package import (
17+
OpcPackage, Part, PartFactory, RelationshipCollection, Unmarshaller
18+
)
1719
from opc.packuri import PACKAGE_URI
1820

1921
from .unitutil import class_mock, method_mock
@@ -94,6 +96,13 @@ def it_constructs_a_part_instance(self, Part_):
9496
assert part == Part_.return_value
9597

9698

99+
class DescribeRelationshipCollection(object):
100+
101+
def it_has_a_len(self):
102+
rels = RelationshipCollection(None)
103+
assert len(rels) == 0
104+
105+
97106
class DescribeUnmarshaller(object):
98107

99108
@pytest.fixture

0 commit comments

Comments
 (0)