Ejemplo n.º 1
0
    def test_config_args(self):
        cfg = _write_config_file("""
[alembic]
migrations = %(base_path)s/db/migrations
""")
        test_cfg = config.Config(cfg.config_file_name,
                                 config_args=dict(base_path="/home/alembic"))
        eq_(test_cfg.get_section_option("alembic", "migrations"),
            "/home/alembic/db/migrations")
Ejemplo n.º 2
0
    def test_config_args(self):
        cfg = _write_config_file("""
[alembic]
migrations = %(base_path)s/db/migrations
""")
        test_cfg = config.Config(
            cfg.config_file_name, config_args=dict(base_path="/home/alembic")
        )
        eq_(
            test_cfg.get_section_option("alembic", "migrations"),
            "/home/alembic/db/migrations")
Ejemplo n.º 3
0
def env():
    r"""Create an environment in which to run this test.

    Creates the environment directory using alembic.testing utilities, and
    additionally creates a revision map and scripts.

    Expressed visually, the map looks like this::

        A
        |
        B
        |
        C
        | \
        D  D0
        |  |  \
        E  E0  E1
        | /   / |
        F   F1  F2
        | /   / |
        G   G2  G3
        |   |  / |
        |   |  | G4
        |  /  / /
        | / / /
        ||/ /
        H--

    Note that ``H`` alone has a "depends_on", namely ``G4``.

    Uses class scope to create different environments for different backends.
    """
    env = staging_env()
    env_file_fixture(_env_content)
    _write_config_file(_cfg_content % (_get_staging_directory(),
                                       sqla_test_config.db_url))
    revs = env._revs = {}

    def gen(rev, head=None, **kw):
        if head:
            kw['head'] = [env._revs[h].revision for h in head.split()]
        revid = '__'.join((rev, util.rev_id()))
        env._revs[rev] = env.generate_revision(revid, rev, splice=True, **kw)

    gen('A')
    gen('B')
    gen('C')
    gen('D')
    gen('D0', 'C')
    gen('E', 'D')
    gen('E0', 'D0')
    gen('E1', 'D0')
    gen('F', 'E E0')
    gen('F1', 'E1')
    gen('F2', 'E1')
    gen('G', 'F F1')
    gen('G2', 'F2')
    gen('G3', 'F2')
    gen('G4', 'G3')
    gen('H', 'G G2', depends_on='G4')

    revids = env._revids = {k: v.revision for k, v in revs.items()}
    env.R = type('R', (object,), revids)
    yield env