def make_frames(self, service_uri = "http://localhost:8080/xmlrpc/xmlrpc", filename = "", *args): document = Movie() isabelle_session = Isabelle_Session(service_uri, filename) contents = self.script isabelle_session.add(contents) #TODO: Poll for change (or comet-push on change?) time.sleep(10) tree = parseString("<document>" + isabelle_session.document_as_xml() + "</document>") for node in tree.documentElement.childNodes: if node.nodeType != Node.TEXT_NODE and node.tagName == "state": document.addFrame(self.state_to_frame(node)) return document
def make_frames(self, prover=None): """ Splits the file stored in self.script into seperate commands, and pairs these commands to their responses as provided by prover. Arguments: - prover: The prover to send commands to. """ document = Movie() command = self.getCommand() while command != None and len(command) != 0: if self.isComment(command): response = None else: response = prover.send(command) id = 0 document.addFrame(Frame(id, command, response)) command = self.getCommand() return document
def make_frames(self, prover = None): """ Splits the file stored in self.script into seperate commands, and pairs these commands to their responses as provided by prover. Arguments: - prover: The prover to send commands to. """ document = Movie() command = self.getCommand() while command != None and len(command) != 0: if self.isComment(command): response = None else: response = prover.send(command) id = 0 document.addFrame(Frame(id, command, response)) command = self.getCommand() return document
class Test_Movie(unittest.TestCase): """ A set of test cases for movies. """ def setUp(self): """ Setup: just construct a movie """ self.movie = Movie() def test_AddFrame(self): """ Addition of a frame in order should yield correct IDs """ frame1 = Frame(command = "command1", response = "response1") self.movie.addFrame(frame1) frame2 = Frame(command = "command2", response = "response2") self.movie.addFrame(frame2) frame3 = Frame(command = "command3", response = "response3") self.movie.addFrame(frame3) self.assertEquals(self.movie.getLength(), 3) self.assertEquals(frame1.getId(), 0) self.assertEquals(frame2.getId(), 1) self.assertEquals(frame3.getId(), 2) def _storeOpenAndCompareMovie(self): self.movie.toFile(TESTFILM_PATH) importMov = Movie() importMov.openFile(TESTFILM_PATH) self.assertEquals(str(self.movie.toxml()), str(importMov.toxml())) def testToFromXML(self): """ Writing and loading an empty Movie should give the same document """ self._storeOpenAndCompareMovie() def testAddToFromXML(self): self.movie.addFrame(Frame(command="cmd", response="resp")) self._storeOpenAndCompareMovie() def testSemiEmptyExport(self): self.movie.addFrame(Frame(command="cmd", response="")) self._storeOpenAndCompareMovie() def testEmptyExport(self): self.movie.addFrame(Frame(command="cmd")) self._storeOpenAndCompareMovie() def testIds(self): """ Test if getFrameById works """ f1 = Frame(command = "cmd1", response = "rsp1") f2 = Frame(command = "cmd2", response = "rsp2") self.movie.addFrame(f1) self.movie.addFrame(f2) f1ById = self.movie.getFrameById(f1.getId()) self.assertEqual(f1, f1ById)