def __init__(self, app_info): """ Application reads the json 'markup' to bootstrap the application framework. :param app_info: :return: """ self.__app_info = app_info markup = load_binder(self.__app_info) self.__app_name = markup['application'] self.__imports = markup['imports'] self.__startup_info = TargetInfo(self.__app_info.module, markup['startup']) # TODO: Controller should __init__ with path to _binder (namespace) -- # i.e., _load_markup(...) from Controller initializer # # self.__markup = load_binder(self.__startup) self.__controller = None self.mainloop = self.__run self.__app = None self.__initialize()
def test_application_import(self): target_module = importlib.import_module('PyLE_Driver_Testing') app_cnf = TargetInfo(target_module, 'sample_1_app.json') application = Application(app_cnf) app_mod_name = app_cnf.module.__name__ app_module = get_import(app_mod_name) self.assertEqual(app_cnf.module, app_module)
def test_member_from_aliased_root(self): member = 'root' target_module = importlib.import_module('PyLE_Driver_Testing') app_cnf = TargetInfo(target_module, 'sample_1a_app.json') application = Application(app_cnf) members = application.extensions self.assertTrue(member in members)
def test_initialization(self): app_info = TargetInfo(test_app_module, 'test_app') exp_name = "App" application = Application(app_info) self.assertTrue(application is not None) self.assertEqual(exp_name, application.name) self.assertEqual([], application.imports) self.assertTrue(application.has_binder)
def test_initialization(self): target_module = importlib.import_module('PyLE_Driver_Testing') app_cnf = TargetInfo(target_module, 'sample_1_app.json') exp_name = "App" application = Application(app_cnf) self.assertTrue(application is not None) self.assertEqual(exp_name, application.name) self.assertTrue(application.has_binder)
def test_initialization(self): target_info = TargetInfo(test_app_module, 'test_app') class AppTest(Bootstrap): def __init__(self): Bootstrap.__init__(self, target_info) app_test = AppTest() self.assertIsNotNone(app_test)
def test_binder(self): app_info = TargetInfo(test_app_module, 'test_app') markup = load_binder(app_info) self.assertTrue('application' in markup) self.assertEqual('App', markup['application']) self.assertTrue('imports' in markup) self.assertEqual([], markup['imports']) self.assertTrue('startup' in markup) self.assertEqual('test_app.views.main', markup['startup'])
def test_initialization(self): view_info = TargetInfo(test_app_module, 'views.main') exp_name = "Main" exp_base = "Frame" controller = Controller(view_info) self.assertTrue(controller is not None) self.assertTrue(controller.has_binder) self.assertEqual(exp_name, controller.name) self.assertEqual(exp_base, controller.base_name)
def test_aliased_import(self): target_module = importlib.import_module('PyLE_Driver_Testing') app_cnf = TargetInfo(target_module, 'sample_1a_app.json') exp_key = 'tk' exp_name = 'tkinter' exp_imports = {exp_key: importlib.import_module(exp_name)} application = Application(app_cnf) self.assertTrue(exp_key in application.imports) self.assertEqual(exp_imports[exp_key], application.imports[exp_key])
def test_member_root(self): member = 'root' target_module = importlib.import_module('PyLE_Driver_Testing') app_cnf = TargetInfo(target_module, 'sample_1_app.json') application = Application(app_cnf) members = application.extensions self.assertTrue(member in members) root = application[member] self.assertIsNotNone(application[member]) self.assertTrue(isinstance(root(), tk.Tk))
def test_initialization(self): target_module = importlib.import_module( 'PyLE_Driver_Testing.test_app.views') add_imports([target_module.__name__, 'tkinter@tk']) view_cnf = TargetInfo(target_module, 'sample_1.json') exp_class = "Main" exp_base = "Frame" controller = Controller(view_cnf) self.assertTrue(controller is not None) self.assertTrue(controller.has_binder) self.assertEqual(exp_class, controller.name) self.assertEqual(exp_base, controller.base_name)
def test_initialization(self): expected_dict = { "application": "App", "imports": [ "tkinter" ], "f:root": "cls-tkinter.Tk", "startup": "test_app.views.sample_1" } target_module = importlib.import_module('PyLE_Driver_Testing') target_info = TargetInfo(target_module, 'sample_1_app.json') class AppTest(Bootstrap): def __init__(self): Bootstrap.__init__(self, target_info) app_test = AppTest() self.assertEqual(expected_dict, app_test.binder) self.assertIsNotNone(app_test)
def __init__(self, file): mod_info = TargetInfo(importlib.import_module('PyLE_Driver_Testing'), file) Bootstrap.__init__(self, mod_info)
import importlib try: from PyLE_Driver import TargetInfo except: import sys # is there a better way to do this? sys.path.insert(1, '/home/pi/RzWare.Pixelbox') print(sys.path) from PyLE_Driver import TargetInfo from PyLE_Driver.bootstrap import Bootstrap _mod_info = TargetInfo(importlib.import_module('PyDE_Pyper'), 'application') class Application(Bootstrap): def __init__(self): Bootstrap.__init__(self, _mod_info) app = Application() app.mainloop()
def test_binder(self): view_info = TargetInfo(test_app_module, 'views.main') markup = load_binder(view_info) self.assertIsNotNone(markup)
import importlib try: from PyLE_Driver import TargetInfo except ImportError: import sys # is there a better way to do this? sys.path.insert(1, '/home/pi/RzWare.Pixelbox') from PyLE_Driver import TargetInfo print(sys.path) from PyLE_Driver.bootstrap import Bootstrap _mod_info = TargetInfo(importlib.import_module('PyLE_Driver_Testing'), 'sample_1_app') class Application(Bootstrap): def __init__(self): Bootstrap.__init__(self, _mod_info) app = Application() app.mainloop()