def add_story_with_content(self, story_id, xml_element_id, xml_element_tag): Story.create(self, story_id, xml_element_id, xml_element_tag, self.working_copy_path) self.designmap.add_stories([story_id]) self.designmap.synchronize() self.init_lazy_references() return self
def test_create(self): from tempfile import mkdtemp idml_working_copy = mkdtemp() story = Story.create(None, "my_story_id", "my_xml_element_id", "my_xml_element_tag", idml_working_copy) self.assertEqual(story.name, 'Stories/Story_my_story_id.xml') self.assertEqual(story.tostring(), b"""<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="7.5"> <Story Self="my_story_id" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n"> <StoryPreference OpticalMarginAlignment="false" OpticalMarginSize="12" FrameType="TextFrameType" StoryOrientation="Horizontal" StoryDirection="LeftToRightDirection"/> <InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false"/> <XMLElement Self="my_xml_element_id" MarkupTag="XMLTag/my_xml_element_tag" XMLContent="my_story_id"/> </Story> </idPkg:Story> """) shutil.rmtree(idml_working_copy)