Skip to content

Commit

Permalink
test: Add feature for .rels file count
Browse files Browse the repository at this point in the history
Make sure that a .rels parts is not written for any part that has no
outgoing relationships.
  • Loading branch information
scanny committed Sep 14, 2021
1 parent d4eb038 commit ce78e00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions features/prs-open-save.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Feature: Round-trip a presentation
Given a presentation with external relationships
When I save and reload the presentation
Then the external relationships are still there
And the package has the expected number of .rels parts
14 changes: 9 additions & 5 deletions features/steps/presentation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# encoding: utf-8

"""
Gherkin step implementations for presentation-level features.
"""

from __future__ import absolute_import
"""Gherkin step implementations for presentation-level features."""

import os
import zipfile

from behave import given, when, then

Expand Down Expand Up @@ -181,6 +178,13 @@ def then_ext_rels_are_preserved(context):
assert rel.target_ref == "https://github.com/scanny/python-pptx"


@then("the package has the expected number of .rels parts")
def then_the_package_has_the_expected_number_of_rels_parts(context):
with zipfile.ZipFile(saved_pptx_path, "r") as z:
member_count = len(z.namelist())
assert member_count == 18, "expected 18, got %d" % member_count


@then("the slide height matches the new value")
def then_slide_height_matches_new_value(context):
presentation = context.presentation
Expand Down

0 comments on commit ce78e00

Please sign in to comment.