Skip to content

Commit

Permalink
sld: add Slide.follow_master_background getter
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Apr 27, 2018
1 parent 2b5bb56 commit 102df6e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 0 additions & 1 deletion features/sld-slide.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Feature: slide properties
| an overridden |


@wip
Scenario Outline: Slide.follow_master_background
Given a Slide object having <default-or-overridden> background as slide
Then slide.follow_master_background is <value>
Expand Down
9 changes: 6 additions & 3 deletions pptx/oxml/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ class CT_Slide(_BaseSlideElement):

@classmethod
def new(cls):
"""
Return a new ``<p:sld>`` element configured as a base slide shape.
"""
"""Return new `p:sld` element configured as base slide shape."""
return parse_xml(cls._sld_xml())

@property
def bg(self):
"""Return `p:bg` grandchild or None if not present."""
return self.cSld.bg

def get_or_add_childTnLst(self):
"""Return parent element for a new `p:video` child element.
Expand Down
14 changes: 14 additions & 0 deletions pptx/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ def background(self):
"""
return super(Slide, self).background

@property
def follow_master_background(self):
"""|True| if this slide inherits the slide master background.
Assigning |False| causes background inheritance from the master to be
interrupted; if there is no custom background for this slide,
a default background is added. If a custom background already exists
for this slide, assigning |False| has no effect.
Assigning |True| causes any custom background for this slide to be
deleted and inheritance from the master restored.
"""
return self._element.bg is None

@property
def has_notes_slide(self):
"""
Expand Down
14 changes: 14 additions & 0 deletions tests/test_slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ def it_provides_access_to_its_background(self, background_fixture):
_BaseSlide_background_.assert_called_once_with()
assert background is background_

def it_knows_whether_it_follows_the_mstr_bkgd(self, follow_get_fixture):
slide, expected_value = follow_get_fixture
follows = slide.follow_master_background
assert follows is expected_value

def it_knows_whether_it_has_a_notes_slide(self, has_notes_slide_fixture):
slide, expected_value = has_notes_slide_fixture
assert slide.has_notes_slide is expected_value
Expand Down Expand Up @@ -365,6 +370,15 @@ def background_fixture(self, _BaseSlide_background_, background_):
_BaseSlide_background_.return_value = background_
return slide, _BaseSlide_background_, background_

@pytest.fixture(params=[
('p:sld/p:cSld', True),
('p:sld/p:cSld/p:bg', False),
])
def follow_get_fixture(self, request):
pSld_cxml, expected_value = request.param
slide = Slide(element(pSld_cxml), None)
return slide, expected_value

@pytest.fixture
def has_notes_slide_fixture(self, part_prop_, slide_part_):
slide = Slide(None, None)
Expand Down

0 comments on commit 102df6e

Please sign in to comment.