This repository was archived by the owner on Jun 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
improve unittests and fix strptime of status datetime for 3.6 #145
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fd2da86
refactor, collect all status tests in the TestSlots class
b40baa9
refactor, parametrize test_geojson
7c88566
refactor, mock requests
1b4ceac
refactor, move example sources
20139f5
add unittest test_overpass_id
7a1bd56
add queries unittests
7208cec
add api errors unittests
56885a7
refactor, move the commented code for updating "example.*" files to t…
883f49a
add deprecation warning messages to deprecated functions
6bfac3a
fix strptime of status datetime
4396fad
use 3.7 future for strptime of status datetime
ef18a2c
refactor, move Python version check to dependency.py
2e4b234
refactor, make "_strptime" a static method
55ab07c
use static "_strptime" method to parse "date" argument of "get" method
0f376ec
fix tests, deprecate 3.6 related functions
mvexel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ eggs/ | |
pip-log.txt | ||
docs/_build/ | ||
Pipfile.lock | ||
venv/ | ||
venv/ | ||
.vscode/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "overpass" | ||
dynamic = ["version"] | ||
description = "Python wrapper for the OpenStreetMap Overpass API" | ||
readme = "README.md" | ||
license.file = "LICENSE.txt" | ||
authors = [ | ||
{ name = "Martijn van Exel", email = "[email protected]" }, | ||
] | ||
keywords = [ | ||
"openstreetmap", | ||
"overpass", | ||
"wrapper", | ||
] | ||
classifiers = [ | ||
"License :: OSI Approved :: Apache Software License", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Scientific/Engineering :: GIS", | ||
"Topic :: Utilities", | ||
] | ||
dependencies = [ | ||
"geojson>=1.0.9", | ||
"requests>=2.3.0", | ||
"shapely>=1.6.4", | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest" | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/mvexel/overpass-api-python-wrapper" | ||
|
||
[tool.hatch.version] | ||
path = "overpass/__init__.py" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = [ | ||
"/overpass", | ||
] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest>=6.2.0 | ||
pytest>=6.2.5 | ||
tox>=3.20.1 | ||
mock>=4.0.3 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
# Set temporary True to update example.json/example.response files with real overpass endpoint data | ||
UPDATE_EXAMPLES = False | ||
|
||
RESOURCE_PATH = os.path.join(os.path.dirname(os.path.abspath(os.path.relpath(__file__))), 'resources') | ||
|
||
|
||
def save_resource(file_name, data): | ||
with open(os.path.join(RESOURCE_PATH, file_name), 'wb') as f: | ||
f.write(data) | ||
|
||
|
||
def load_resource(file_name): | ||
with open(os.path.join(RESOURCE_PATH, file_name), 'rb') as f: | ||
result = f.read() | ||
return result | ||
|
||
|
||
def update_examples(): | ||
import pickle | ||
import geojson | ||
import overpass | ||
|
||
query = 'rel(6518385);out body geom;way(10322303);out body geom;node(4927326183);' | ||
api = overpass.API() | ||
osm_geo = api.get(query, verbosity='body geom') | ||
save_resource('example.response', pickle.dumps(api._get_from_overpass(f'[out:json];{query}out body geom;'), | ||
protocol=2)) | ||
save_resource('example.json', geojson.dumps(osm_geo).encode('utf8')) | ||
|
||
|
||
if UPDATE_EXAMPLES: | ||
UPDATE_EXAMPLES = False | ||
update_examples() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
import mock | ||
|
||
import overpass | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def requests(monkeypatch): | ||
mocker = mock.MagicMock() | ||
mocker.response = overpass.api.requests.Response() | ||
|
||
mocker.response.status_code = 200 | ||
|
||
mocker.get.return_value = mocker.response | ||
mocker.post.return_value = mocker.response | ||
|
||
monkeypatch.setattr(overpass.api, 'requests', mocker) | ||
|
||
yield mocker |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use pathlib instead of os.path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar. What does that give us?