def test_from_xml(self): """ Test that a frame is constructed from XML, properly. """ xml = BeautifulStoneSoup("""<film><frame framenumber="0"> <command>Spam</command> <response>Eggs</response> <command-coqdoc><div>Spam</div></command-coqdoc> </frame></fiml> """) frame = Coqdoc_Frame() frame.fromxml(xml.frame) self.assertEquals("Spam", frame.getCommand()) self.assertEquals("Eggs", frame.getResponse()) self.assertEquals("<div>Spam</div>", str(frame.get_coqdoc_command()))
def fromxml(self, xml): """ Unmarshall the given xml tree into a Coqdoc_movie. """ self._frames = [] self._scenes = [] for frame_xml in xml.film.findAll(name="frame"): frame = Coqdoc_Frame() frame.fromxml(frame_xml) self.addFrame(frame) for scene_xml in xml.scenes.findAll(name="scene", recursive=False): scene = Scene() scene.fromxml(scene_xml) self._replace_frames(scene) self.add_scene(scene)
def fromxml(self, xml): """ Unmarshall the given xml tree into a Coqdoc_movie. """ self._frames = [] self._scenes = [] for frame_xml in xml.film.findAll(name="frame"): frame = Coqdoc_Frame() frame.fromxml(frame_xml) self.addFrame(frame) for scene_xml in xml.scenes.findAll(name="scene", recursive = False): scene = Scene() scene.fromxml(scene_xml) self._replace_frames(scene) self.add_scene(scene)