def setUp(self): """Call before every test case.""" try: config.add_section('Shop') except: pass try: config.add_section('Services') config.add_section('Activities') except: pass config.set('Shop', 'voucher_percentage', '33.3334') config.set('Shop', 'fee_percentage', '1') config.set('Shop', 'name', 'enviclean') config.set('Services', 'services', '') config.set('Activities', 'start', 'test_kernel') config.set('Activities', 'package', 'red.tests') self.kernel = Kernel(None)
def start(self): global config ### Initialize Logger initConfig(self.configFile,logging.getLogger("config")) logger = logging.getLogger("red") logger.info("Zebra 14 is booting") app = QtGui.QApplication(sys.argv) #logger.info('Reading config; ' + self.configFile) #config.read(self.configFile) self.kernel = Kernel(app) signal.signal(signal.SIGINT, self.signal_handler) self.window = None ##### This is QT load UI ###### services = config.get('Services','Services').split(",") if "display" in services: logger.info("Zebra GUI is initiating") from red.mainwindow import MainWindow self.window = MainWindow.instance() self.window.show() logger.info('Zebra GUI initiated') ############################### self.kernel.start() ###### This fellow must be run in the end ###### if "display" in services: sys.exit(app.exec_())
class Test_KernelTest(unittest.TestCase): @classmethod def setUpClass(self): initConfig("test_meta.conf") def setUp(self): """Call before every test case.""" try: config.add_section('Shop') except: pass try: config.add_section('Services') config.add_section('Activities') except: pass config.set('Shop', 'voucher_percentage', '33.3334') config.set('Shop', 'fee_percentage', '1') config.set('Shop', 'name', 'enviclean') config.set('Services', 'services', '') config.set('Activities', 'start', 'test_kernel') config.set('Activities', 'package', 'red.tests') self.kernel = Kernel(None) def tearDown(self): """Call after every test case.""" pass def testReceive(self): """ Tests the receive method """ """ Should not give an exception, but should log some stuff """ self.kernel.receive("self.stop()", {"head" : "echo"}) """ This tests that the message gets delivered to the activity""" self.kernel.activity = MockActivity(self.kernel) self.kernel.receive("test", {"head" : "echo"}) self.assertTrue(self.kernel.activity.received) def testSwitchActivity(self): """ Tests switch activity """ """ This tests that it does not throw renegade exceptions""" self.kernel.switchActivity("something_nonexistant") """ This tests that it does not throw renegade exceptions""" self.kernel.switchActivity("test_kernel") self.kernel._initializeActivity("test_kernel") self.kernel.receive("test", {"head" : "echo"}) self.assertTrue(Test_kernel.received) def testSend(self): try: self.kernel.send("test", {"head" : "hello"}) self.assertTrue(False) except Exception: self.assertTrue(True)