class LoadingWindowTest(TestCase): def setUp(self): self.editor = Edile() self.cm = ConfigManager() self.cm.writeConfig("/dev/ttyUSB1","") def tearDown(self): pass def test_sendScript_without_file(self): plugin = ciaa_plugin.mnu_EDUCIAA() plugin.item_Load_Script(None,self.editor.plugin_interface) timeout=15 while(plugin.loadScriptWindow.lblStatus.get_text()!="ERROR: Save File first" and timeout>0): time.sleep(1) print(plugin.loadScriptWindow.lblStatus.get_text()) timeout-=1 self.assertGreater(timeout,0) def test_sendScript(self): self.editor.load_file("tests/test.py") plugin = ciaa_plugin.mnu_EDUCIAA() plugin.item_Load_Script(None,self.editor.plugin_interface) print(">>>>>>>>>>>>>>> PRESS RESET BUTTON MANUALLY") timeout=15 while(plugin.loadScriptWindow.lblStatus.get_text()!="File copied" and timeout>0): time.sleep(1) print(plugin.loadScriptWindow.lblStatus.get_text()) timeout-=1 self.assertGreater(timeout,0) def test_sendScript_wrong_port(self): self.editor.load_file("tests/test.py") self.cm.writeConfig("/dev/ttyUSBXXXXXX","") # wrong port plugin = ciaa_plugin.mnu_EDUCIAA() plugin.item_Load_Script(None,self.editor.plugin_interface) timeout=15 while(plugin.loadScriptWindow.lblStatus.get_text()!="Invalid PORT" and timeout>0): time.sleep(1) print(plugin.loadScriptWindow.lblStatus.get_text()) timeout-=1 self.assertGreater(timeout,0)
class EditorTest(TestCase): def setUp(self): self.editor = Edile() def tearDown(self): pass def test_openFileOk(self): flagOk=False try: self.editor.load_file("tests/test.py") flagOk=True except: pass self.assertEqual(flagOk,True) def test_openFileInvalid(self): flagOk=False try: self.editor.load_file("tests/test2.py") flagOk=True except: pass self.assertEqual(flagOk,False) def test_saveFile(self): buff = self.editor.text_view.get_buffer() buff.insert_at_cursor("Test String") self.editor.write_file("tests/testOut.py") self.editor.load_file("tests/testOut.py") text = buff.get_text(buff.get_start_iter(), buff.get_end_iter()) self.assertEqual("Test String",text)