def test_replace_blok_by_another_in_one_step(self): registry = self.init_registry(None) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok13 = Blok.query().filter(Blok.name == 'test-blok13').first() registry.upgrade(install=('test-blok1',)) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok13.state, 'uninstalled') registry.upgrade(uninstall=('test-blok1',), install=('test-blok13',)) self.assertEqual(testblok1.state, 'uninstalled') self.assertEqual(testblok13.state, 'installed')
def test_replace_blok_by_another_in_one_step(self): registry = self.init_registry(None) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok13 = Blok.query().filter(Blok.name == 'test-blok13').first() registry.upgrade(install=('test-blok1', )) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok13.state, 'uninstalled') registry.upgrade(uninstall=('test-blok1', ), install=('test-blok13', )) self.assertEqual(testblok1.state, 'uninstalled') self.assertEqual(testblok13.state, 'installed')
def test_install(self): registry = self.init_registry(None) Blok = registry.System.Blok registry.upgrade(install=('test-blok6',)) testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok6 = Blok.query().filter(Blok.name == 'test-blok6').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok6.state, 'installed') self.assertEqual(testblok6.version, '1.0.0') self.assertEqual(testblok6.installed_version, '1.0.0')
def test_install(self): registry = self.init_registry(None) Blok = registry.System.Blok registry.upgrade(install=('test-blok6', )) testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok6 = Blok.query().filter(Blok.name == 'test-blok6').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok6.state, 'installed') self.assertEqual(testblok6.version, '1.0.0') self.assertEqual(testblok6.installed_version, '1.0.0')
def test_update_required(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok2', )) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok2 = Blok.query().filter(Blok.name == 'test-blok2').first() testblok1.version = '2.0.0' testblok2.version = '2.0.0' registry.upgrade(update=('test-blok1', )) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.installed_version, '2.0.0') self.assertEqual(testblok2.state, 'installed') self.assertEqual(testblok2.installed_version, '2.0.0')
def test_uninstall(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok2', )) registry.upgrade(uninstall=('test-blok2', )) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok2 = Blok.query().filter(Blok.name == 'test-blok2').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertIsNone(testblok2.installed_version)
def test_uninstall(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok2',)) registry.upgrade(uninstall=('test-blok2',)) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok2 = Blok.query().filter(Blok.name == 'test-blok2').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertIsNone(testblok2.installed_version)
def test_update_required(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok2',)) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok2 = Blok.query().filter(Blok.name == 'test-blok2').first() testblok1.version = '2.0.0' testblok2.version = '2.0.0' registry.upgrade(update=('test-blok1',)) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.installed_version, '2.0.0') self.assertEqual(testblok2.state, 'installed') self.assertEqual(testblok2.installed_version, '2.0.0')
def load(self): """Load all the actor defined in all the installed bloks""" Blok = self.registry.System.Blok for blok in Blok.list_by_state('installed'): b = BlokManager.get(blok) if hasattr(b, 'declare_actors'): b.declare_actors(self.registry)
def test_update_conditionnal(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok5',)) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() testblok1.version = '2.0.0' testblok4.version = '2.0.0' testblok5.version = '2.0.0' registry.upgrade(update=('test-blok1',)) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.installed_version, '2.0.0') self.assertEqual(testblok4.state, 'installed') self.assertEqual(testblok4.installed_version, '1.0.0') self.assertEqual(testblok5.state, 'installed') self.assertEqual(testblok5.installed_version, '2.0.0')
def test_update_conditionnal(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok5', )) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() testblok1.version = '2.0.0' testblok4.version = '2.0.0' testblok5.version = '2.0.0' registry.upgrade(update=('test-blok1', )) self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.installed_version, '2.0.0') self.assertEqual(testblok4.state, 'installed') self.assertEqual(testblok4.installed_version, '1.0.0') self.assertEqual(testblok5.state, 'installed') self.assertEqual(testblok5.installed_version, '2.0.0')
def test_blok_exist(self): registry = self.init_registry(None) Blok = registry.System.Blok query = Blok.query().filter(Blok.name == 'test-blok2') if not query.count(): self.fail('No blok found') testblok2 = query.first() self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertIsNone(testblok2.installed_version) self.assertEqual(testblok2.short_description, 'Test blok2')
def test_blok_exist(self): registry = self.init_registry(None) Blok = registry.System.Blok query = Blok.query().filter(Blok.name == 'test-blok2') if not query.count(): self.fail('No blok found') testblok2 = query.first() self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertEqual(testblok2.installed_version, None) self.assertEqual(testblok2.short_description, 'Test blok2')
def test_install_1by1(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok1',)) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok4.state, 'uninstalled') self.assertEqual(testblok4.version, '1.0.0') self.assertEqual(testblok4.installed_version, None) self.assertEqual(testblok5.state, 'uninstalled') self.assertEqual(testblok5.version, '1.0.0') self.assertEqual(testblok5.installed_version, None) registry.upgrade(install=('test-blok4',)) testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok4.state, 'installed') self.assertEqual(testblok4.version, '1.0.0') self.assertEqual(testblok4.installed_version, '1.0.0') self.assertEqual(testblok5.state, 'installed') self.assertEqual(testblok5.version, '1.0.0') self.assertEqual(testblok5.installed_version, '1.0.0')
def test_install_1by1(self): registry = self.init_registry(None) registry.upgrade(install=('test-blok1', )) Blok = registry.System.Blok testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok4.state, 'uninstalled') self.assertEqual(testblok4.version, '1.0.0') self.assertIsNone(testblok4.installed_version) self.assertEqual(testblok5.state, 'uninstalled') self.assertEqual(testblok5.version, '1.0.0') self.assertIsNone(testblok5.installed_version) registry.upgrade(install=('test-blok4', )) testblok1 = Blok.query().filter(Blok.name == 'test-blok1').first() testblok4 = Blok.query().filter(Blok.name == 'test-blok4').first() testblok5 = Blok.query().filter(Blok.name == 'test-blok5').first() self.assertEqual(testblok1.state, 'installed') self.assertEqual(testblok1.version, '1.0.0') self.assertEqual(testblok1.installed_version, '1.0.0') self.assertEqual(testblok4.state, 'installed') self.assertEqual(testblok4.version, '1.0.0') self.assertEqual(testblok4.installed_version, '1.0.0') self.assertEqual(testblok5.state, 'installed') self.assertEqual(testblok5.version, '1.0.0') self.assertEqual(testblok5.installed_version, '1.0.0')
def load(self): from os.path import join tmpl = Template() Blok = self.registry.System.Blok for blok in Blok.list_by_state('installed'): b = BlokManager.get(blok) if hasattr(b, 'views'): bpath = BlokManager.getPath(blok) for template in b.views: with open(join(bpath, template), 'r') as fp: tmpl.load_file(fp) tmpl.compile() self.registry.furetui_views = tmpl
def load(self): from os.path import join tmpl = Template() Blok = self.registry.System.Blok for blok in Blok.list_by_state('installed'): b = BlokManager.get(blok) if hasattr(b, 'views'): bpath = BlokManager.getPath(blok) for template in b.views: with open(join(bpath, template), 'r') as fp: tmpl.load_file(fp) tmpl.compile() self.registry.erpblok_views = tmpl
def test_blok_exist(self): registry = self.init_registry(None) Blok = registry.System.Blok query = Blok.query().filter(Blok.name == 'test-blok3') if not query.count(): self.fail('No blok found') testblok2 = query.first() self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertEqual(testblok2.installed_version, None) long_description = ".. This file is a part of the AnyBlok project\n.." long_description += "\n.. Copyright (C) 2014 Jean-Sebastien SUZANNE" long_description += " <*****@*****.**>\n..\n.. This Source Code " long_description += "Form is subject to the terms of the Mozilla " long_description += "Public License,\n.. v. 2.0. If a copy of the MPL " long_description += "was not distributed with this file,You can\n.. " long_description += "obtain one at http://mozilla.org/MPL/2.0/.\n\n" long_description += "Test blok3\n" self.assertEqual(testblok2.long_description, long_description)
def test_blok_exist(self): registry = self.init_registry(None) Blok = registry.System.Blok query = Blok.query().filter(Blok.name == 'test-blok3') if not query.count(): self.fail('No blok found') testblok2 = query.first() self.assertEqual(testblok2.state, 'uninstalled') self.assertEqual(testblok2.version, '1.0.0') self.assertIsNone(testblok2.installed_version) long_description = ".. This file is a part of the AnyBlok project\n.." long_description += "\n.. Copyright (C) 2014 Jean-Sebastien SUZANNE" long_description += " <*****@*****.**>\n..\n.. This Source Code " long_description += "Form is subject to the terms of the Mozilla " long_description += "Public License,\n.. v. 2.0. If a copy of the MPL " long_description += "was not distributed with this file,You can\n.. " long_description += "obtain one at http://mozilla.org/MPL/2.0/.\n\n" long_description += "Test blok3\n" self.assertEqual(testblok2.long_description, long_description)