コード例 #1
0
 def test_with_context(self):
     from a import application
     with application.app_context():
         assert 'a.b' in settings['PACKAGES']
         assert settings['PACKAGES'][-1] == 'a.b'
         assert len(settings) > 0
         assert len(list(iter(settings))) > 0
コード例 #2
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_table_name_simple_with_context(self):
        from example import application

        context = application.app_context()
        context.push()

        from example import models

        assert models.ExampleWall.__table__.name == 'example_examplewall'

        context.pop()
コード例 #3
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def setup(self):
        # Perform base setup.
        super().setup()

        # Ensure all models are created.
        from a import application as app
        app.metadata['a'].create_all(app.databases['default'])
        app.metadata['a.b'].create_all(app.databases['default'])

        # Establish the context.
        self.context = app.app_context()
        self.context.push()
コード例 #4
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_tables_simple_with_context(self):
        from example import application

        context = application.app_context()
        context.push()

        from example import models as e

        assert e.ExampleWall.__table__ in self._tables(e.ExampleWall)
        assert e.ExampleBlock.__table__ in self._tables(e.ExampleBlock)

        context.pop()
コード例 #5
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_tables_nested_with_context(self):
        from a import application

        context = application.app_context()
        context.push()

        from a import models as a
        from a.b import models as b
        from a.b.c import models as c

        assert c.CBlock.__table__ in self._tables(b.BBlock)
        assert c.CBlock.__table__ in self._tables(b.BWall)
        assert c.CBlock.__table__ not in self._tables(a.ABlock)
        assert c.CBlock.__table__ not in self._tables(a.AWall)
        assert c.CBlock.__table__ in self._tables(c.CBlock)
        assert c.CBlock.__table__ in self._tables(c.CWall)

        assert b.BBlock.__table__ in self._tables(c.CBlock)
        assert b.BBlock.__table__ in self._tables(c.CWall)
        assert b.BBlock.__table__ not in self._tables(a.ABlock)
        assert b.BBlock.__table__ not in self._tables(a.AWall)
        assert b.BBlock.__table__ in self._tables(b.BBlock)
        assert b.BBlock.__table__ in self._tables(b.BWall)

        assert a.ABlock.__table__ not in self._tables(b.BBlock)
        assert a.ABlock.__table__ not in self._tables(b.BWall)
        assert a.ABlock.__table__ not in self._tables(c.CBlock)
        assert a.ABlock.__table__ not in self._tables(c.CWall)
        assert a.ABlock.__table__ in self._tables(a.ABlock)
        assert a.ABlock.__table__ in self._tables(a.AWall)

        assert c.CWall.__table__ in self._tables(b.BBlock)
        assert c.CWall.__table__ in self._tables(b.BWall)
        assert c.CWall.__table__ not in self._tables(a.ABlock)
        assert c.CWall.__table__ not in self._tables(a.AWall)
        assert c.CWall.__table__ in self._tables(c.CBlock)
        assert c.CWall.__table__ in self._tables(c.CWall)

        assert b.BWall.__table__ in self._tables(c.CBlock)
        assert b.BWall.__table__ in self._tables(c.CWall)
        assert b.BWall.__table__ not in self._tables(a.ABlock)
        assert b.BWall.__table__ not in self._tables(a.AWall)
        assert b.BWall.__table__ in self._tables(b.BBlock)
        assert b.BWall.__table__ in self._tables(b.BWall)

        assert a.AWall.__table__ not in self._tables(b.BBlock)
        assert a.AWall.__table__ not in self._tables(b.BWall)
        assert a.AWall.__table__ not in self._tables(c.CBlock)
        assert a.AWall.__table__ not in self._tables(c.CWall)
        assert a.AWall.__table__ in self._tables(a.ABlock)
        assert a.AWall.__table__ in self._tables(a.AWall)

        context.pop()
コード例 #6
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_class_registry_simple_with_context(self):
        from example import application

        context = application.app_context()
        context.push()

        from example import models

        assert models.ExampleWall in self._get_registry(models.ExampleWall)
        assert models.ExampleBlock in self._get_registry(models.ExampleBlock)

        context.pop()
コード例 #7
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_class_registry_basic_with_context(self):
        from basic_db import application

        context = application.app_context()
        context.push()

        import basic_db

        assert basic_db.Wall in self._get_registry(basic_db.Wall)
        assert basic_db.Block in self._get_registry(basic_db.Block)

        context.pop()
コード例 #8
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_class_registry_nested_with_context(self):
        from a import application

        context = application.app_context()
        context.push()

        from a import models as a
        from a.b import models as b
        from a.b.c import models as c

        assert c.CBlock in self._get_registry(b.BBlock)
        assert c.CBlock in self._get_registry(b.BWall)
        assert c.CBlock not in self._get_registry(a.ABlock)
        assert c.CBlock not in self._get_registry(a.AWall)
        assert c.CBlock in self._get_registry(c.CBlock)
        assert c.CBlock in self._get_registry(c.CWall)

        assert b.BBlock in self._get_registry(c.CBlock)
        assert b.BBlock in self._get_registry(c.CWall)
        assert b.BBlock not in self._get_registry(a.ABlock)
        assert b.BBlock not in self._get_registry(a.AWall)
        assert b.BBlock in self._get_registry(b.BBlock)
        assert b.BBlock in self._get_registry(b.BWall)

        assert a.ABlock not in self._get_registry(b.BBlock)
        assert a.ABlock not in self._get_registry(b.BWall)
        assert a.ABlock not in self._get_registry(c.CBlock)
        assert a.ABlock not in self._get_registry(c.CWall)
        assert a.ABlock in self._get_registry(a.ABlock)
        assert a.ABlock in self._get_registry(a.AWall)

        assert c.CWall in self._get_registry(b.BBlock)
        assert c.CWall in self._get_registry(b.BWall)
        assert c.CWall not in self._get_registry(a.ABlock)
        assert c.CWall not in self._get_registry(a.AWall)
        assert c.CWall in self._get_registry(c.CBlock)
        assert c.CWall in self._get_registry(c.CWall)

        assert b.BWall in self._get_registry(c.CBlock)
        assert b.BWall in self._get_registry(c.CWall)
        assert b.BWall not in self._get_registry(a.ABlock)
        assert b.BWall not in self._get_registry(a.AWall)
        assert b.BWall in self._get_registry(b.BBlock)
        assert b.BWall in self._get_registry(b.BWall)

        assert a.AWall not in self._get_registry(b.BBlock)
        assert a.AWall not in self._get_registry(b.BWall)
        assert a.AWall not in self._get_registry(c.CBlock)
        assert a.AWall not in self._get_registry(c.CWall)
        assert a.AWall in self._get_registry(a.ABlock)
        assert a.AWall in self._get_registry(a.AWall)

        context.pop()
コード例 #9
0
ファイル: test_alchemist.py プロジェクト: joneshf/alchemist
    def test_current_app(self):
        from a import application

        config = application.config
        context = application.app_context()
        context.push()

        from alchemist import application

        config == application.config

        context.pop()
コード例 #10
0
    def test_current_app(self):
        from a import application

        config = application.config
        context = application.app_context()
        context.push()

        from alchemist import application

        config == application.config

        context.pop()
コード例 #11
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
    def test_table_name_nested_with_context(self):
        from a import application

        context = application.app_context()
        context.push()

        from a import models as a
        from a.b import models as b
        from a.b.c import models as c

        assert a.ABlock.__table__.name == 'a_ablock'
        assert b.BWall.__table__.name == 'a_b_bwall'
        assert c.CWall.__table__.name == 'a_b_cwall'

        context.pop()
コード例 #12
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
 def test_package_resolution_simple_with_context(self):
     from example import application
     with application.app_context():
         assert models._package_of('example.models') == 'example'
コード例 #13
0
ファイル: test_db.py プロジェクト: joneshf/alchemist
 def test_package_resolution_nested_with_context(self):
     from a import application
     with application.app_context():
         assert models._package_of('a.models') == 'a'
         assert models._package_of('a.b.models') == 'a.b'
         assert models._package_of('a.b.c.models') == 'a.b'