Skip to content

Commit 152f049

Browse files
author
Steve Canny
committed
opc: refactor it_matches_override_on_partname()
Extract fixture
1 parent 6c74e23 commit 152f049

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/opc/test_pkgreader.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,8 @@ def it_can_construct_from_ct_item_xml(self, from_xml_fixture):
271271
assert ct_map._defaults == expected_defaults
272272
assert ct_map._overrides == expected_overrides
273273

274-
def it_matches_overrides(self):
275-
# test data --------------------
276-
partname = PackURI('/part/name1.xml')
277-
content_type = 'app/vnd.type1'
278-
# fixture ----------------------
279-
ct_map = _ContentTypeMap()
280-
ct_map._overrides = {partname: content_type}
281-
# verify -----------------------
274+
def it_matches_an_override_on_partname(self, match_override_fixture):
275+
ct_map, partname, content_type = match_override_fixture
282276
assert ct_map[partname] == content_type
283277

284278
def it_falls_back_to_defaults(self):
@@ -320,6 +314,18 @@ def from_xml_fixture(self):
320314
expected_overrides[partname] = content_type
321315
return content_types_xml, expected_defaults, expected_overrides
322316

317+
@pytest.fixture(params=[
318+
('/foo/bar.xml', '/foo/bar.xml'),
319+
])
320+
def match_override_fixture(self, request):
321+
partname_str, should_match_partname_str = request.param
322+
partname = PackURI(partname_str)
323+
should_match_partname = PackURI(should_match_partname_str)
324+
content_type = 'appl/vnd-foobar'
325+
ct_map = _ContentTypeMap()
326+
ct_map._add_override(partname, content_type)
327+
return ct_map, should_match_partname, content_type
328+
323329
def _xml_from(self, entries):
324330
"""
325331
Return XML for a [Content_Types].xml based on items in *entries*.

0 commit comments

Comments
 (0)