Exemplo n.º 1
0
    def setUp(self):
        uri = ("sqlite:///:memory:")

        self.uri_left = get_temporary_uri(uri)
        self.uri_right = get_temporary_uri(uri)

        self.alembic_config_left = make_alembic_config(self.uri_left,
                                                       alembic_root)
        self.alembic_config_right = make_alembic_config(
            self.uri_right, alembic_root)

        new_db(self.uri_left)
        new_db(self.uri_right)
Exemplo n.º 2
0
    def setUp(self):
        uri = (
            "mysql+mysqlconnector://root:password@localhost:3306/alembicverify"
        )

        self.uri_left = get_temporary_uri(uri)
        self.uri_right = get_temporary_uri(uri)

        self.alembic_config_left = make_alembic_config(self.uri_left,
                                                       alembic_root)
        self.alembic_config_right = make_alembic_config(
            self.uri_right, alembic_root)

        new_db(self.uri_left)
        new_db(self.uri_right)
Exemplo n.º 3
0
    def setUp(self):
        # from aiida.backends.sqlalchemy.tests.migration_test import versions
        from aiida.backends.sqlalchemy.migrations import versions

        self.migr_method_dir_path = os.path.dirname(
            os.path.realpath(utils.__file__))
        # Set the alembic script directory location
        self.alembic_dpath = os.path.join(self.migr_method_dir_path,
                                          utils.ALEMBIC_REL_PATH)

        # Constructing the versions directory
        versions_dpath = os.path.join(os.path.dirname(versions.__file__))

        # Setting dynamically the the path to the alembic configuration
        # (this is where the env.py file can be found)
        self.alembic_cfg_left = Config()
        self.alembic_cfg_left.set_main_option('script_location',
                                              self.alembic_dpath)
        # Setting dynamically the versions directory. These are the
        # migration scripts to pass from one version to the other. The
        # default ones are overridden with test-specific migrations.
        self.alembic_cfg_left.set_main_option('version_locations',
                                              versions_dpath)

        # The correction URL to the SQLA database of the current
        # AiiDA connection
        curr_db_url = sa.engine.url

        # Create new urls for the two new databases
        self.db_url_left = get_temporary_uri(str(curr_db_url))
        self.db_url_right = get_temporary_uri(str(curr_db_url))

        # Put the correct database url to the database used by alembic
        self.alembic_cfg_left.set_main_option("sqlalchemy.url",
                                              self.db_url_left)

        # Database creation
        new_database(self.db_url_left)
        new_database(self.db_url_right)
Exemplo n.º 4
0
    def setUp(self):
        """Test setup."""
        uri = (get_config('SQLALCHEMY_DATABASE_URI'))
        alembic_ini = os.path.abspath('migrations/alembic.ini')

        self.uri_left = get_temporary_uri(uri)
        self.uri_right = get_temporary_uri(uri)

        self.alembic_config_left = Config(alembic_ini)
        self.alembic_config_left.set_main_option("script_location",
                                                 alembic_root)
        self.alembic_config_left.set_main_option("sqlalchemy.url",
                                                 self.uri_left)

        self.alembic_config_right = Config(alembic_ini)
        self.alembic_config_right.set_main_option("script_location",
                                                  alembic_root)
        self.alembic_config_right.set_main_option("sqlalchemy.url",
                                                  self.uri_right)

        new_db(self.uri_left)
        new_db(self.uri_right)
Exemplo n.º 5
0
def create_temp_config(app):
    """Create alembic config with temp DB."""

    uri = app.config['SQLALCHEMY_DATABASE_URI']
    config_dir = os.path.abspath(os.path.dirname('migrations/'))
    config = Config(os.path.join(config_dir, 'alembic.ini'))

    uri_temp = get_temporary_uri(uri)

    config.set_main_option("script_location", config_dir)
    config.set_main_option("sqlalchemy.url", uri_temp)

    return config
Exemplo n.º 6
0
    def create_app(self):
        """
        Переопределние метода create_app из LiveServerTestCase.

        Для того чтобы скормить тестам наше приложение.
        """
        uri = (get_config('DB_CONFIG'))
        self.testdb_uri = get_temporary_uri(uri)
        new_db(self.testdb_uri)
        engine = create_engine(self.testdb_uri)
        engine.execute("CREATE EXTENSION pgcrypto;")
        prepare_schema_from_models(self.testdb_uri, Base)
        app = create_app(self.testdb_uri)
        app.config['TESTING'] = True
        app.config['DEBUG'] = True
        app.config['LIVESERVER_PORT'] = 8943
        app.config['LIVESERVER_TIMEOUT'] = 10
        return app
Exemplo n.º 7
0
def uri_right(db_uri):
    return get_temporary_uri(db_uri)
Exemplo n.º 8
0
def uri_left(db_uri):
    return get_temporary_uri(db_uri)