<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import pytest <EOL> from datetime import datetime , timedelta <EOL> from pptx . opc . constants import CONTENT_TYPE as CT <EOL> from pptx . oxml . parts . coreprops import CT_CoreProperties <EOL> from pptx . parts . coreprops import CoreProperties <EOL> class DescribeCoreProperties ( object ) : <EOL> def it_knows_the_string_property_values ( self , str_prop_get_fixture ) : <EOL> core_properties , prop_name , expected_value = str_prop_get_fixture <EOL> actual_value = getattr ( core_properties , prop_name ) <EOL> assert actual_value == expected_value <EOL> def it_can_change_the_string_property_values ( self , str_prop_set_fixture ) : <EOL> core_properties , prop_name , value , expected_xml = str_prop_set_fixture <EOL> setattr ( core_properties , prop_name , value ) <EOL> assert core_properties . _element . xml == expected_xml <EOL> def it_knows_the_date_property_values ( self , date_prop_get_fixture ) : <EOL> core_properties , prop_name , expected_datetime = date_prop_get_fixture <EOL> actual_datetime = getattr ( core_properties , prop_name ) <EOL> assert actual_datetime == expected_datetime <EOL> def it_can_change_the_date_property_values ( self , date_prop_set_fixture ) : <EOL> core_properties , prop_name , value , expected_xml = ( <EOL> date_prop_set_fixture <EOL> ) <EOL> setattr ( core_properties , prop_name , value ) <EOL> assert core_properties . _element . xml == expected_xml <EOL> def it_knows_the_revision_number ( self , revision_get_fixture ) : <EOL> core_properties , expected_revision = revision_get_fixture <EOL> assert core_properties . revision == expected_revision <EOL> def it_can_change_the_revision_number ( self , revision_set_fixture ) : <EOL> core_properties , revision , expected_xml = revision_set_fixture <EOL> core_properties . revision = revision <EOL> assert core_properties . _element . xml == expected_xml <EOL> def it_can_construct_a_default_core_props ( self ) : <EOL> core_props = CoreProperties . default ( ) <EOL> assert isinstance ( core_props , CoreProperties ) <EOL> assert core_props . content_type is CT . OPC_CORE_PROPERTIES <EOL> assert core_props . partname == '<STR_LIT>' <EOL> assert isinstance ( core_props . _element , CT_CoreProperties ) <EOL> assert core_props . title == '<STR_LIT>' <EOL> assert core_props . last_modified_by == '<STR_LIT>' <EOL> assert core_props . revision == <NUM_LIT:1> <EOL> modified_timedelta = datetime . utcnow ( ) - core_props . modified <EOL> max_expected_timedelta = timedelta ( seconds = <NUM_LIT:2> ) <EOL> assert modified_timedelta < max_expected_timedelta <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> ) ) , <EOL> ( '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT> ) ) , <EOL> ( '<STR_LIT>' , None ) , <EOL> ] ) <EOL> def date_prop_get_fixture ( self , request , core_properties ) : <EOL> prop_name , expected_datetime = request . param <EOL> return core_properties , prop_name , expected_datetime <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:4> , <NUM_LIT:4> ) , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def date_prop_set_fixture ( self , request ) : <EOL> prop_name , tagname , value , str_val , attrs = request . param <EOL> coreProperties = self . coreProperties ( None , None ) <EOL> core_properties = CoreProperties . load ( <EOL> None , None , coreProperties , None <EOL> ) <EOL> expected_xml = self . coreProperties ( tagname , str_val , attrs ) <EOL> return core_properties , prop_name , value , expected_xml <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:title>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:version>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def str_prop_get_fixture ( self , request , core_properties ) : <EOL> prop_name , expected_value = request . param <EOL> return core_properties , prop_name , expected_value <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:version>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def str_prop_set_fixture ( self , request ) : <EOL> prop_name , tagname , value = request . param <EOL> coreProperties = self . coreProperties ( None , None ) <EOL> core_properties = CoreProperties . load ( <EOL> None , None , coreProperties , None <EOL> ) <EOL> expected_xml = self . coreProperties ( tagname , value ) <EOL> return core_properties , prop_name , value , expected_xml <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , ( None , <NUM_LIT:0> ) , ( '<STR_LIT>' , <NUM_LIT:0> ) , ( '<STR_LIT>' , <NUM_LIT:0> ) , ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> ] ) <EOL> def revision_get_fixture ( self , request ) : <EOL> str_val , expected_revision = request . param <EOL> tagname = '<STR_LIT>' if str_val is None else '<STR_LIT>' <EOL> coreProperties = self . coreProperties ( tagname , str_val ) <EOL> core_properties = CoreProperties . load ( <EOL> None , None , coreProperties , None <EOL> ) <EOL> return core_properties , expected_revision <EOL> @ pytest . fixture ( params = [ <EOL> ( <NUM_LIT> , '<STR_LIT>' ) , <EOL> ] ) <EOL> def revision_set_fixture ( self , request ) : <EOL> value , str_val = request . param <EOL> coreProperties = self . coreProperties ( None , None ) <EOL> core_properties = CoreProperties . load ( <EOL> None , None , coreProperties , None <EOL> ) <EOL> expected_xml = self . coreProperties ( '<STR_LIT>' , str_val ) <EOL> return core_properties , value , expected_xml <EOL> def coreProperties ( self , tagname , str_val , attrs = '<STR_LIT>' ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> if not tagname : <EOL> child_element = '<STR_LIT>' <EOL> elif not str_val : <EOL> child_element = '<STR_LIT>' % ( tagname , attrs ) <EOL> else : <EOL> child_element = ( <EOL> '<STR_LIT>' % ( tagname , attrs , str_val , tagname ) <EOL> ) <EOL> return tmpl % child_element <EOL> @ pytest . fixture <EOL> def core_properties ( self ) : <EOL> xml = ( <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> ) <EOL> return CoreProperties . load ( None , None , xml , None ) </s>
