Esempio n. 1
0
def test_import_osm_data_simple_ignore_no_data(table_factory,
                                               osm2pgsql_options):
    table_factory('place')

    database_import.import_osm_data(Path('file.pbf'),
                                    osm2pgsql_options,
                                    ignore_errors=True)
def test_import_osm_data_default_cache(temp_db_cursor, osm2pgsql_options):
    temp_db_cursor.execute('CREATE TABLE place (id INT)')
    temp_db_cursor.execute('INSERT INTO place values (1)')

    osm2pgsql_options['osm2pgsql_cache'] = 0

    database_import.import_osm_data(Path(__file__), osm2pgsql_options)
Esempio n. 3
0
def test_import_osm_data_multifile(table_factory, tmp_path, osm2pgsql_options):
    table_factory('place', content=((1, ), ))
    osm2pgsql_options['osm2pgsql_cache'] = 0

    files = [tmp_path / 'file1.osm', tmp_path / 'file2.osm']
    for f in files:
        f.write_text('test')

    database_import.import_osm_data(files, osm2pgsql_options)
Esempio n. 4
0
def test_import_osm_data_default_cache(table_factory, osm2pgsql_options,
                                       capfd):
    table_factory('place', content=((1, ), ))

    osm2pgsql_options['osm2pgsql_cache'] = 0

    database_import.import_osm_data(Path(__file__), osm2pgsql_options)
    captured = capfd.readouterr()

    assert f'--cache {osm2pgsql_options["osm2pgsql_cache"]}' in captured.out
Esempio n. 5
0
def test_import_osm_data_simple(table_factory, osm2pgsql_options, capfd):
    table_factory('place', content=((1, ), ))

    database_import.import_osm_data(Path('file.pbf'), osm2pgsql_options)
    captured = capfd.readouterr()

    assert '--create' in captured.out
    assert '--output gazetteer' in captured.out
    assert f'--style {osm2pgsql_options["osm2pgsql_style"]}' in captured.out
    assert f'--number-processes {osm2pgsql_options["threads"]}' in captured.out
    assert f'--cache {osm2pgsql_options["osm2pgsql_cache"]}' in captured.out
    assert 'file.pbf' in captured.out
Esempio n. 6
0
def test_import_osm_data_drop(temp_db_conn, temp_db_cursor, tmp_path, osm2pgsql_options):
    temp_db_cursor.execute('CREATE TABLE place (id INT)')
    temp_db_cursor.execute('CREATE TABLE planet_osm_nodes (id INT)')
    temp_db_cursor.execute('INSERT INTO place values (1)')

    flatfile = tmp_path / 'flatfile'
    flatfile.write_text('touch')

    osm2pgsql_options['flatnode_file'] = str(flatfile.resolve())

    database_import.import_osm_data('file.pdf', osm2pgsql_options, drop=True)

    assert not flatfile.exists()
    assert not temp_db_conn.table_exists('planet_osm_nodes')
Esempio n. 7
0
def test_import_osm_data_multifile(table_factory, tmp_path, osm2pgsql_options,
                                   capfd):
    table_factory('place', content=((1, ), ))
    osm2pgsql_options['osm2pgsql_cache'] = 0

    files = [tmp_path / 'file1.osm', tmp_path / 'file2.osm']
    for f in files:
        f.write_text('test')

    database_import.import_osm_data(files, osm2pgsql_options)
    captured = capfd.readouterr()

    assert 'file1.osm' in captured.out
    assert 'file2.osm' in captured.out
Esempio n. 8
0
def test_import_osm_data_drop(table_factory, temp_db_conn, tmp_path,
                              osm2pgsql_options):
    table_factory('place', content=((1, ), ))
    table_factory('planet_osm_nodes')

    flatfile = tmp_path / 'flatfile'
    flatfile.write_text('touch')

    osm2pgsql_options['flatnode_file'] = str(flatfile.resolve())

    database_import.import_osm_data(Path('file.pbf'),
                                    osm2pgsql_options,
                                    drop=True)

    assert not flatfile.exists()
    assert not temp_db_conn.table_exists('planet_osm_nodes')
def test_import_osm_data_simple_no_data(temp_db_cursor, osm2pgsql_options):
    temp_db_cursor.execute('CREATE TABLE place (id INT)')

    with pytest.raises(UsageError, match='No data.*'):
        database_import.import_osm_data('file.pdf', osm2pgsql_options)
def test_import_osm_data_simple(temp_db_cursor, osm2pgsql_options):
    temp_db_cursor.execute('CREATE TABLE place (id INT)')
    temp_db_cursor.execute('INSERT INTO place values (1)')

    database_import.import_osm_data('file.pdf', osm2pgsql_options)
Esempio n. 11
0
def test_import_osm_data_simple_no_data(table_factory, osm2pgsql_options):
    table_factory('place')

    with pytest.raises(UsageError, match='No data.*'):
        database_import.import_osm_data(Path('file.pbf'), osm2pgsql_options)
Esempio n. 12
0
def test_import_osm_data_simple(table_factory, osm2pgsql_options):
    table_factory('place', content=((1, ), ))

    database_import.import_osm_data(Path('file.pbf'), osm2pgsql_options)
Esempio n. 13
0
def test_import_osm_data_default_cache(table_factory, osm2pgsql_options):
    table_factory('place', content=((1, ), ))

    osm2pgsql_options['osm2pgsql_cache'] = 0

    database_import.import_osm_data(Path(__file__), osm2pgsql_options)