def test_install_module_fail_access(temp_db_conn, tmp_path):
    (tmp_path / 'nominatim.so').write_text('TEST nomiantim.so')

    with pytest.raises(UsageError, match='.*module cannot be accessed.*'):
        database_import.install_module(tmp_path,
                                       tmp_path,
                                       '',
                                       conn=temp_db_conn)
Пример #2
0
def install_database_module_in_project_directory(conn, config, paths, **_):
    """ Install database module in project directory.

        The database module needs to be present in the project directory
        since those were introduced.
    """
    database_import.install_module(paths.module_dir, paths.project_dir,
                                   config.DATABASE_MODULE_PATH, conn=conn)
def test_install_module(tmp_path):
    src_dir = tmp_path / 'source'
    src_dir.mkdir()
    (src_dir / 'nominatim.so').write_text('TEST nomiantim.so')

    project_dir = tmp_path / 'project'
    project_dir.mkdir()

    database_import.install_module(src_dir, project_dir, '')

    outfile = project_dir / 'module' / 'nominatim.so'

    assert outfile.exists()
    assert outfile.read_text() == 'TEST nomiantim.so'
    assert outfile.stat().st_mode == 33261
def test_install_module_custom(tmp_path):
    (tmp_path / 'nominatim.so').write_text('TEST nomiantim.so')

    database_import.install_module(tmp_path, tmp_path, str(tmp_path.resolve()))

    assert not (tmp_path / 'module').exists()