def core_properties(self): """ Instance of |CoreProperties| holding the read/write Dublin Core document properties for this presentation. Creates a default core properties part if one is not present (not common). """ try: return self.part_related_by(RT.CORE_PROPERTIES) except KeyError: core_props = CoreProperties.default() self.relate_to(core_props, RT.CORE_PROPERTIES) return core_props
def core_properties(self): """ Instance of |CoreProperties| holding the read/write Dublin Core document properties for this presentation. Creates a default core properties part if one is not present (not common). """ try: return self.part_related_by(RT.CORE_PROPERTIES) except KeyError: core_props = CoreProperties.default() self.relate_to(core_props, RT.CORE_PROPERTIES) return core_props
def it_can_construct_a_default_core_props(self): core_props = CoreProperties.default() # verify ----------------------- assert isinstance(core_props, CoreProperties) assert core_props.content_type is CT.OPC_CORE_PROPERTIES assert core_props.partname == '/docProps/core.xml' assert isinstance(core_props._element, CT_CoreProperties) assert core_props.title == 'PowerPoint Presentation' assert core_props.last_modified_by == 'python-pptx' assert core_props.revision == 1 # core_props.modified only stores time with seconds resolution, so # comparison needs to be a little loose (within two seconds) modified_timedelta = datetime.utcnow() - core_props.modified max_expected_timedelta = timedelta(seconds=2) assert modified_timedelta < max_expected_timedelta
def it_can_construct_a_default_core_props(self): core_props = CoreProperties.default() # verify ----------------------- assert isinstance(core_props, CoreProperties) assert core_props.content_type is CT.OPC_CORE_PROPERTIES assert core_props.partname == '/docProps/core.xml' assert isinstance(core_props._element, CT_CoreProperties) assert core_props.title == 'PowerPoint Presentation' assert core_props.last_modified_by == 'python-pptx' assert core_props.revision == 1 # core_props.modified only stores time with seconds resolution, so # comparison needs to be a little loose (within two seconds) modified_timedelta = datetime.utcnow() - core_props.modified max_expected_timedelta = timedelta(seconds=2) assert modified_timedelta < max_expected_timedelta
def test_it_can_construct_default_core_props(self): core_props = CoreProperties.default() # verify ----------------------- assert_that(core_props, is_(instance_of(CoreProperties))) assert_that(core_props.content_type, is_(CT.OPC_CORE_PROPERTIES)) assert_that(core_props.partname, is_('/docProps/core.xml')) assert_that(core_props._element, is_(instance_of(CT_CoreProperties))) assert_that(core_props.title, is_('PowerPoint Presentation')) assert_that(core_props.last_modified_by, is_('python-pptx')) assert_that(core_props.revision, is_(1)) # core_props.modified only stores time with seconds resolution, so # comparison needs to be a little loose (within two seconds) modified_timedelta = datetime.utcnow() - core_props.modified max_expected_timedelta = timedelta(seconds=2) assert_that(modified_timedelta, less_than(max_expected_timedelta))