X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/da20881096fb4f38ed0226279f4ce1cf6f95e94f..691ec0858601f91adb942d2cb5d3a9b844005780:/test/bdd/steps/table_compare.py?ds=inline diff --git a/test/bdd/steps/table_compare.py b/test/bdd/steps/table_compare.py index 2e71d943..ca6c3020 100644 --- a/test/bdd/steps/table_compare.py +++ b/test/bdd/steps/table_compare.py @@ -1,3 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2022 by the Nominatim developer community. +# For a full list of authors see the git log. """ Functions to facilitate accessing and comparing the content of DB tables. """ @@ -56,11 +62,14 @@ class NominatimID: ','.join(['*'] + (extra_columns or [])), table) cur.execute(query, (pid, )) - def get_place_id(self, cur): + def get_place_id(self, cur, allow_empty=False): """ Look up the place id for the ID. Throws an assertion if the ID is not unique. """ self.query_osm_id(cur, "SELECT place_id FROM placex WHERE {}") + if cur.rowcount == 0 and allow_empty: + return None + assert cur.rowcount == 1, \ "Place ID {!s} not unique. Found {} entries.".format(self, cur.rowcount)