コード例 #1
0
ファイル: imp.py プロジェクト: Gnonpi/AnyBlok
    def imports(self):
        """ Imports modules and / or packages listed in the blok path"""
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager

        RegistryManager.init_blok(self.blok)
        b = BlokManager.get(self.blok)
        b.import_declaration_module()
コード例 #2
0
ファイル: imp.py プロジェクト: AnyBlok/AnyBlok
    def imports(self):
        """ Imports modules and / or packages listed in the blok path"""
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager

        RegistryManager.init_blok(self.blok)
        b = BlokManager.get(self.blok)
        b.import_declaration_module()
コード例 #3
0
    def add_testCore(self, request, bloks_loaded):
        def reset():
            EnvironmentManager.set('current_blok', None)
            del RegistryManager.loaded_bloks['testCore' + self._corename]

        request.addfinalizer(reset)
        RegistryManager.init_blok('testCore' + self._corename)
        EnvironmentManager.set('current_blok', 'testCore' + self._corename)
コード例 #4
0
    def init_env(self, request):

        def revert():
            EnvironmentManager.set('current_blok', None)
            del RegistryManager.loaded_bloks['testModel']

        request.addfinalizer(revert)
        RegistryManager.init_blok('testModel')
        EnvironmentManager.set('current_blok', 'testModel')
コード例 #5
0
    def init_env(self, request):
        def revert():
            EnvironmentManager.set('current_blok', None)
            del RegistryManager.loaded_bloks['testCore']
            RegistryManager.undeclare_core('test')

        request.addfinalizer(revert)
        RegistryManager.declare_core('test')
        RegistryManager.init_blok('testCore')
        EnvironmentManager.set('current_blok', 'testCore')
コード例 #6
0
    def test_init_blok(self):
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            self.assertIn(
                core, RegistryManager.loaded_bloks['newblok']['Core'].keys())
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][core], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
コード例 #7
0
    def test_init_blok(self):
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            self.assertIn(
                core, RegistryManager.loaded_bloks['newblok']['Core'].keys())
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][core], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
コード例 #8
0
    def test_add_entry(self):
        RegistryManager.declare_entry('Other')
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for entry in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                      'InstrumentedList'):
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][entry], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Other'],
                         {'registry_names': []})
コード例 #9
0
    def test_init_blok(self):
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        assert is_exist
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            assert core in RegistryManager.loaded_bloks['newblok'][
                'Core'].keys()
            assert RegistryManager.loaded_bloks['newblok']['Core'][core] == []

        assert RegistryManager.loaded_bloks['newblok']['Model'] == {
            'registry_names': []
        }
        assert RegistryManager.loaded_bloks['newblok']['Mixin'] == {
            'registry_names': []
        }
コード例 #10
0
    def test_add_entry(self):
        RegistryManager.declare_entry('Other')
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for entry in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                      'InstrumentedList'):
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][entry], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Other'],
                         {'registry_names': []})
コード例 #11
0
 def test_global_property(self):
     RegistryManager.declare_entry('Other')
     blok = 'newblok'
     RegistryManager.init_blok(blok)
     try:
         oldblok = EnvironmentManager.get('current_blok')
         EnvironmentManager.set('current_blok', blok)
         assert not RegistryManager.has_blok_property('myproperty')
         RegistryManager.add_or_replace_blok_property('myproperty', 2)
         assert RegistryManager.has_blok_property('myproperty')
         assert RegistryManager.get_blok_property('myproperty') == 2
         RegistryManager.add_or_replace_blok_property('myproperty', 3)
         assert RegistryManager.get_blok_property('myproperty') == 3
         RegistryManager.remove_blok_property('myproperty')
         assert not RegistryManager.has_blok_property('myproperty')
     finally:
         EnvironmentManager.set('current_blok', oldblok)
コード例 #12
0
    def test_add_entry(self):
        RegistryManager.declare_entry('Other')
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        assert is_exist
        for entry in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                      'InstrumentedList'):
            assert RegistryManager.loaded_bloks['newblok']['Core'][entry] == []

        assert RegistryManager.loaded_bloks['newblok']['Model'] == {
            'registry_names': []
        }
        assert RegistryManager.loaded_bloks['newblok']['Mixin'] == {
            'registry_names': []
        }
        assert RegistryManager.loaded_bloks['newblok']['Other'] == {
            'registry_names': []
        }
コード例 #13
0
ファイル: imp.py プロジェクト: Gnonpi/AnyBlok
    def reload(self):
        """ Reload all the imports for this module

        :exception: ImportManagerException
        """
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager
        from anyblok.environment import EnvironmentManager

        b = BlokManager.get(self.blok)
        if not hasattr(b, 'reload_declaration_module'):
            return

        try:
            EnvironmentManager.set('reload', True)
            RegistryManager.init_blok(self.blok)
            b.reload_declaration_module(reload_wraper)
        finally:
            EnvironmentManager.set('reload', False)
コード例 #14
0
ファイル: imp.py プロジェクト: AnyBlok/AnyBlok
    def reload(self):
        """ Reload all the imports for this module

        :exception: ImportManagerException
        """
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager
        from anyblok.environment import EnvironmentManager

        b = BlokManager.get(self.blok)
        if not hasattr(b, 'reload_declaration_module'):
            return

        try:
            EnvironmentManager.set('reload', True)
            RegistryManager.init_blok(self.blok)
            b.reload_declaration_module(reload_module)
        finally:
            EnvironmentManager.set('reload', False)
コード例 #15
0
    def test_init_blok_with_other_entry(self):
        RegistryManager.declare_entry('Other')
        hasOther = 'Other' in RegistryManager.declared_entries
        assert hasOther
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        assert is_exist
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            assert core in RegistryManager.loaded_bloks['newblok'][
                'Core'].keys()
            assert RegistryManager.loaded_bloks['newblok']['Core'][core] == []

        assert RegistryManager.loaded_bloks['newblok']['Model'] == {
            'registry_names': []
        }
        assert RegistryManager.loaded_bloks['newblok']['Mixin'] == {
            'registry_names': []
        }
        assert RegistryManager.loaded_bloks['newblok']['Other'] == {
            'registry_names': []
        }
コード例 #16
0
 def test_global_property(self):
     RegistryManager.declare_entry('Other')
     blok = 'newblok'
     RegistryManager.init_blok(blok)
     try:
         oldblok = EnvironmentManager.get('current_blok')
         EnvironmentManager.set('current_blok', blok)
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
         RegistryManager.add_or_replace_blok_property('myproperty', 2)
         self.assertEqual(
             RegistryManager.has_blok_property('myproperty'), True)
         self.assertEqual(
             RegistryManager.get_blok_property('myproperty'), 2)
         RegistryManager.add_or_replace_blok_property('myproperty', 3)
         self.assertEqual(
             RegistryManager.get_blok_property('myproperty'), 3)
         RegistryManager.remove_blok_property('myproperty')
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
     finally:
         EnvironmentManager.set('current_blok', oldblok)
コード例 #17
0
    def test_add_callback(self):

        def callback():
            pass

        RegistryManager.declare_entry('Other', assemble_callback=callback,
                                      initialize_callback=callback)
        hasModel = 'Model' in RegistryManager.declared_entries
        hasMixin = 'Mixin' in RegistryManager.declared_entries
        hasOther = 'Other' in RegistryManager.declared_entries
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)

        cb = Model.assemble_callback
        hasModelCb = cb == RegistryManager.callback_assemble_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_assemble_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        cb = Model.initialize_callback
        hasModelCb = cb == RegistryManager.callback_initialize_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_initialize_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        hasCore = 'Core' in RegistryManager.loaded_bloks['newblok']
        hasModel = 'Model' in RegistryManager.loaded_bloks['newblok']
        hasMixin = 'Mixin' in RegistryManager.loaded_bloks['newblok']
        hasOther = 'Other' in RegistryManager.loaded_bloks['newblok']
        self.assertEqual(hasCore, True)
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)
コード例 #18
0
    def test_add_callback(self):
        def callback():
            pass

        RegistryManager.declare_entry('Other',
                                      assemble_callback=callback,
                                      initialize_callback=callback)
        hasModel = 'Model' in RegistryManager.declared_entries
        hasMixin = 'Mixin' in RegistryManager.declared_entries
        hasOther = 'Other' in RegistryManager.declared_entries
        assert hasModel
        assert hasMixin
        assert hasOther

        cb = Model.assemble_callback
        hasModelCb = cb == RegistryManager.callback_assemble_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_assemble_entries['Other']
        assert hasModelCb
        assert hasOtherCb

        cb = Model.initialize_callback
        hasModelCb = cb == RegistryManager.callback_initialize_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_initialize_entries['Other']
        assert hasModelCb
        assert hasOtherCb

        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        assert is_exist
        hasCore = 'Core' in RegistryManager.loaded_bloks['newblok']
        hasModel = 'Model' in RegistryManager.loaded_bloks['newblok']
        hasMixin = 'Mixin' in RegistryManager.loaded_bloks['newblok']
        hasOther = 'Other' in RegistryManager.loaded_bloks['newblok']
        assert hasCore
        assert hasModel
        assert hasMixin
        assert hasOther
コード例 #19
0
 def test_global_property(self):
     RegistryManager.declare_entry('Other')
     blok = 'newblok'
     RegistryManager.init_blok(blok)
     try:
         oldblok = EnvironmentManager.get('current_blok')
         EnvironmentManager.set('current_blok', blok)
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
         RegistryManager.add_or_replace_blok_property('myproperty', 2)
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          True)
         self.assertEqual(RegistryManager.get_blok_property('myproperty'),
                          2)
         RegistryManager.add_or_replace_blok_property('myproperty', 3)
         self.assertEqual(RegistryManager.get_blok_property('myproperty'),
                          3)
         RegistryManager.remove_blok_property('myproperty')
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
     finally:
         EnvironmentManager.set('current_blok', oldblok)
コード例 #20
0
    def test_add_callback(self):
        def callback():
            pass

        RegistryManager.declare_entry('Other',
                                      assemble_callback=callback,
                                      initialize_callback=callback)
        hasModel = 'Model' in RegistryManager.declared_entries
        hasMixin = 'Mixin' in RegistryManager.declared_entries
        hasOther = 'Other' in RegistryManager.declared_entries
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)

        cb = Model.assemble_callback
        hasModelCb = cb == RegistryManager.callback_assemble_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_assemble_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        cb = Model.initialize_callback
        hasModelCb = cb == RegistryManager.callback_initialize_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_initialize_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        hasCore = 'Core' in RegistryManager.loaded_bloks['newblok']
        hasModel = 'Model' in RegistryManager.loaded_bloks['newblok']
        hasMixin = 'Mixin' in RegistryManager.loaded_bloks['newblok']
        hasOther = 'Other' in RegistryManager.loaded_bloks['newblok']
        self.assertEqual(hasCore, True)
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)
コード例 #21
0
 def setUpClass(cls):
     super(TestRegistryEntry, cls).setUpClass()
     RegistryManager.declare_entry('Other')
     RegistryManager.init_blok('testEntry')
     EnvironmentManager.set('current_blok', 'testEntry')
コード例 #22
0
ファイル: test_mixin.py プロジェクト: AnyBlok/AnyBlok
 def setUpClass(cls):
     super(TestCoreInterfaceMixin, cls).setUpClass()
     RegistryManager.init_blok('testMixin')
     EnvironmentManager.set('current_blok', 'testMixin')
コード例 #23
0
 def setUpClass(cls):
     super(TestRegistryCore, cls).setUpClass()
     RegistryManager.declare_core('test')
     RegistryManager.init_blok('testCore')
     EnvironmentManager.set('current_blok', 'testCore')
コード例 #24
0
 def setUpClass(cls):
     super(TestCoreInterfaceCoreBase, cls).setUpClass()
     RegistryManager.init_blok('testCore' + cls._corename)
     EnvironmentManager.set('current_blok', 'testCore' + cls._corename)
コード例 #25
0
ファイル: test_mixin.py プロジェクト: Gnonpi/AnyBlok
 def setUpClass(cls):
     super(TestCoreInterfaceMixin, cls).setUpClass()
     RegistryManager.init_blok('testMixin')
     EnvironmentManager.set('current_blok', 'testMixin')
コード例 #26
0
ファイル: test_model.py プロジェクト: jssuzanne/AnyBlok
 def setUpClass(cls):
     super(TestModel, cls).setUpClass()
     RegistryManager.init_blok('testModel')
     EnvironmentManager.set('current_blok', 'testModel')
コード例 #27
0
ファイル: test_core.py プロジェクト: AnyBlok/AnyBlok
 def setUpClass(cls):
     super(TestCoreInterfaceCoreBase, cls).setUpClass()
     RegistryManager.init_blok('testCore' + cls._corename)
     EnvironmentManager.set('current_blok', 'testCore' + cls._corename)
コード例 #28
0
 def setUpClass(cls):
     super(TestModel, cls).setUpClass()
     RegistryManager.init_blok('testModel')
     EnvironmentManager.set('current_blok', 'testModel')
コード例 #29
0
ファイル: test_registry_core.py プロジェクト: AnyBlok/AnyBlok
 def setUpClass(cls):
     super(TestRegistryCore, cls).setUpClass()
     RegistryManager.declare_core('test')
     RegistryManager.init_blok('testCore')
     EnvironmentManager.set('current_blok', 'testCore')