Skip to content

Commit

Permalink
Fix tests, some default coordinates used in tests were updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jan 6, 2025
1 parent 263c060 commit 33cb086
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions QuickOSM/core/utilities/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def check_processing_enable() -> Tuple[bool, str, str]:
""" Check if Processing is enabled. """
# https://github.com/3liz/QuickOSM/issues/422
# https://github.com/3liz/QuickOSM/issues/352
# https://github.com/3liz/QuickOSM/pull/517
if 'processing' in qgis.utils.plugins:
return True, '', ''

Expand Down
7 changes: 7 additions & 0 deletions QuickOSM/test/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__copyright__ = 'Copyright 2021, 3Liz'
__license__ = 'GPL version 3'
__email__ = '[email protected]'

# For "La Souterraine" town
TOWN_NAME = 'La Souterraine'
TOWN_COORDS = '46.2374832,1.4857176'
27 changes: 14 additions & 13 deletions QuickOSM/test/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from qgis.testing import unittest

from QuickOSM.quick_osm_processing.provider import Provider
from QuickOSM.test.definitions import TOWN_COORDS, TOWN_NAME

__copyright__ = 'Copyright 2021, 3Liz'
__license__ = 'GPL version 3'
Expand Down Expand Up @@ -53,7 +54,7 @@ def test_build_in_area_query(self):
result = processing.run(
'quickosm:buildqueryinsidearea',
{
'AREA': 'La Souterraine',
'AREA': TOWN_NAME,
'KEY': 'amenity',
'SERVER': 'https://z.overpass-api.de/api/interpreter',
'TIMEOUT': 25,
Expand Down Expand Up @@ -84,7 +85,7 @@ def test_build_around_area_query(self):
result = processing.run(
'quickosm:buildqueryaroundarea',
{
'AREA': 'La Souterraine',
'AREA': TOWN_NAME,
'DISTANCE': 1000,
'KEY': 'amenity',
'SERVER': 'https://lz4.overpass-api.de/api/interpreter',
Expand All @@ -95,18 +96,18 @@ def test_build_around_area_query(self):

result_expected = {
'OUTPUT_URL':
'https://lz4.overpass-api.de/api/interpreter?data=[out:xml]'
' [timeout:25];%0A(%0A node[%22amenity%22%3D%22bench%22]'
'(around:1000, 46.2383347,1.4861387);%0A way[%22amenity%22%3D%22bench%22]'
'(around:1000, 46.2383347,1.4861387);%0A relation[%22amenity%22%3D%22bench%22]'
'(around:1000, 46.2383347,1.4861387);%0A);%0A(._;%3E;);%0Aout'
' body;&info=QgisQuickOSMPlugin',
f'https://lz4.overpass-api.de/api/interpreter?data=[out:xml]'
f' [timeout:25];%0A(%0A node[%22amenity%22%3D%22bench%22]'
f'(around:1000, {TOWN_COORDS});%0A way[%22amenity%22%3D%22bench%22]'
f'(around:1000, {TOWN_COORDS});%0A relation[%22amenity%22%3D%22bench%22]'
f'(around:1000, {TOWN_COORDS});%0A);%0A(._;%3E;);%0Aout'
f' body;&info=QgisQuickOSMPlugin',
'OUTPUT_OQL_QUERY':
'[out:xml] [timeout:25];\n(\n'
' node["amenity"="bench"](around:1000, 46.2383347,1.4861387);\n'
' way["amenity"="bench"](around:1000, 46.2383347,1.4861387);\n'
' relation["amenity"="bench"](around:1000, 46.2383347,1.4861387);'
'\n);\n(._;>;);\nout body;'
f'[out:xml] [timeout:25];\n(\n'
f' node["amenity"="bench"](around:1000, {TOWN_COORDS});\n'
f' way["amenity"="bench"](around:1000, {TOWN_COORDS});\n'
f' relation["amenity"="bench"](around:1000, {TOWN_COORDS});'
f'\n);\n(._;>;);\nout body;'
}

self.assertEqual(result_expected, result)
Expand Down
11 changes: 6 additions & 5 deletions QuickOSM/test/test_processing_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from QuickOSM.qgis_plugin_tools.tools.resources import plugin_test_data_path
from QuickOSM.quick_osm_processing.provider import Provider
from QuickOSM.test.definitions import TOWN_COORDS, TOWN_NAME
from QuickOSM.test.mocked_web_server import (
SequentialHandler,
install_http_handler,
Expand Down Expand Up @@ -143,10 +144,10 @@ def test_process_around_query(self):
handler = SequentialHandler()
handler.add(
'GET',
'/interpreter?data=[out:xml]%20[timeout:25];%0A(%0A%20%20%20%20node[%22amenity%22%3D%22bench%22]'
'(around:1500,%2046.2383347,1.4861387);%0A%20%20%20%20way[%22amenity%22%3D%22bench%22]'
'(around:1500,%2046.2383347,1.4861387);%0A%20%20%20%20relation[%22amenity%22%3D%22bench%22]'
'(around:1500,%2046.2383347,1.4861387);%0A);%0A(._;%3E;);%0Aout%20body;&info=QgisQuickOSMPlugin',
f'/interpreter?data=[out:xml]%20[timeout:25];%0A(%0A%20%20%20%20node[%22amenity%22%3D%22bench%22]'
f'(around:1500,%20{TOWN_COORDS});%0A%20%20%20%20way[%22amenity%22%3D%22bench%22]'
f'(around:1500,%20{TOWN_COORDS});%0A%20%20%20%20relation[%22amenity%22%3D%22bench%22]'
f'(around:1500,%20{TOWN_COORDS});%0A);%0A(._;%3E;);%0Aout%20body;&info=QgisQuickOSMPlugin',
200,
{'Content-type': 'text/xml'},
open(plugin_test_data_path('overpass', 'empty_osm_file.xml'), encoding='utf8').read(),
Expand All @@ -155,7 +156,7 @@ def test_process_around_query(self):
result = processing.run(
'quickosm:downloadosmdataaroundareaquery',
{
'AREA': 'La Souterraine',
'AREA': TOWN_NAME,
'DISTANCE': 1500,
'KEY': 'amenity',
'SERVER': f'http://localhost:{self.port}/interpreter',
Expand Down

0 comments on commit 33cb086

Please sign in to comment.