コード例 #1
0
def test_get_head_revision(_get_revision_mock):
    config, engine, script = Mock(), Mock(), Mock()

    result = get_head_revision(config, engine, script)

    assert _get_revision_mock.return_value == result
    _get_revision_mock.assert_called_once_with(
        config, engine, script, revision_type='head')
コード例 #2
0
    def test_upgrade_and_downgrade(self, uri_left, alembic_config_left):
        """Test all migrations up and down.
        Tests that we can apply all migrations from a brand new empty
        database, and also that we can remove them all.
        """
        setup_extensions(uri_left)
        engine, script = prepare_schema_from_migrations(
            uri_left, alembic_config_left)
        head = get_head_revision(alembic_config_left, engine, script)
        current = get_current_revision(alembic_config_left, engine, script)

        assert head == current

        while current is not None:
            command.downgrade(alembic_config_left, '-1')
            current = get_current_revision(alembic_config_left, engine, script)
コード例 #3
0
def test_upgrade_and_downgrade(uri_left, alembic_config_left):
    """Test all migrations up and down.

    Tests that we can apply all migrations from a brand new empty
    database, and also that we can remove them all.
    """
    engine, script = prepare_schema_from_migrations(
        uri_left, alembic_config_left)

    head = get_head_revision(alembic_config_left, engine, script)
    current = get_current_revision(alembic_config_left, engine, script)

    assert head == current

    while current is not None:
        command.downgrade(alembic_config_left, '-1')
        current = get_current_revision(alembic_config_left, engine, script)