mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 01:47:57 +00:00
simplify property test table implementation
This commit is contained in:
@@ -17,7 +17,7 @@ SRC_DIR = (Path(__file__) / '..' / '..' / '..').resolve()
|
|||||||
sys.path.insert(0, str(SRC_DIR / 'src'))
|
sys.path.insert(0, str(SRC_DIR / 'src'))
|
||||||
|
|
||||||
from nominatim_db.config import Configuration
|
from nominatim_db.config import Configuration
|
||||||
from nominatim_db.db import connection
|
from nominatim_db.db import connection, properties
|
||||||
from nominatim_db.db.sql_preprocessor import SQLPreprocessor
|
from nominatim_db.db.sql_preprocessor import SQLPreprocessor
|
||||||
import nominatim_db.tokenizer.factory
|
import nominatim_db.tokenizer.factory
|
||||||
|
|
||||||
@@ -159,7 +159,14 @@ def load_sql(temp_db_conn, country_row):
|
|||||||
def property_table(load_sql, temp_db_conn):
|
def property_table(load_sql, temp_db_conn):
|
||||||
load_sql('tables/nominatim_properties.sql')
|
load_sql('tables/nominatim_properties.sql')
|
||||||
|
|
||||||
return mocks.MockPropertyTable(temp_db_conn)
|
class _PropTable:
|
||||||
|
def set(self, name, value):
|
||||||
|
properties.set_property(temp_db_conn, name, value)
|
||||||
|
|
||||||
|
def get(self, name):
|
||||||
|
return properties.get_property(temp_db_conn, name)
|
||||||
|
|
||||||
|
return _PropTable()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ Custom mocks for testing.
|
|||||||
"""
|
"""
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from nominatim_db.db import properties
|
|
||||||
|
|
||||||
|
|
||||||
class MockPlacexTable:
|
class MockPlacexTable:
|
||||||
""" A placex table for testing.
|
""" A placex table for testing.
|
||||||
@@ -66,20 +64,3 @@ class MockPlacexTable:
|
|||||||
place_id = cur.fetchone()[0]
|
place_id = cur.fetchone()[0]
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
return place_id
|
return place_id
|
||||||
|
|
||||||
|
|
||||||
class MockPropertyTable:
|
|
||||||
""" A property table for testing.
|
|
||||||
"""
|
|
||||||
def __init__(self, conn):
|
|
||||||
self.conn = conn
|
|
||||||
|
|
||||||
def set(self, name, value):
|
|
||||||
""" Set a property in the table to the given value.
|
|
||||||
"""
|
|
||||||
properties.set_property(self.conn, name, value)
|
|
||||||
|
|
||||||
def get(self, name):
|
|
||||||
""" Set a property in the table to the given value.
|
|
||||||
"""
|
|
||||||
return properties.get_property(self.conn, name)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user