Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
docentYT committed Mar 3, 2023
1 parent 0ccbb83 commit b84b4cb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.3] - 2023-03-03

### Fixed

- Fixed the non-setting of the "visible" attribute.

## [0.1.2] - 2023-03-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# osm_easy_api

![Tests](https://github.com/docentYT/automated-python-tests-testing-repo/actions/workflows/tests.yaml/badge.svg)
![coverage](https://github.com/docentYT/osm_easy_api/blob/main/coverage-badge.svg)
![coverage](https://raw.githubusercontent.com/docentYT/osm_easy_api/0ccbb839a128ad6f69f7e0d160c4eb32d273389a/coverage-badge.svg)
[![PyPI version](https://badge.fury.io/py/osm_easy_api.svg)](https://badge.fury.io/py/osm_easy_api)

Python package for parsing osm diffs and communicating with the osm api. See API.txt for list of supported endpoints.
Expand Down
2 changes: 1 addition & 1 deletion src/osm_easy_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "0.1.2"
VERSION = "0.1.3"

from .data_classes import Node, Way, Relation, OsmChange, Action, Tags
from .diff import Diff, Frequency
Expand Down
16 changes: 14 additions & 2 deletions src/osm_easy_api/diff/diff_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,40 @@ def _if_correct(element: ElementTree.Element, tags: Tags | str) -> bool:
# return good_tags_count == len(tags)

def _create_node_from_attributes(attributes: dict) -> Node:
visible = None
if attributes.get("visible"):
visible = True if attributes["visible"] == "true" else False
return Node(
id = int( attributes["id"] ),
visible = visible,
version = int( attributes["version"] ),
timestamp = str( attributes["timestamp"] ),
user_id = int( attributes["uid"] ),
changeset_id = int( attributes["changeset"] ),
latitude = str( attributes.get("lat") ),
longitude = str( attributes.get("lon") )
latitude = str( attributes.get("lat") ),
longitude = str( attributes.get("lon") )
)

def _create_way_from_attributes(attributes: dict) -> Way:
visible = None
if attributes.get("visible"):
visible = True if attributes["visible"] == "true" else False
return Way(
id = int( attributes["id"] ),
visible = visible,
version = int( attributes["version"] ),
timestamp = str( attributes["timestamp"] ),
user_id = int( attributes["uid"] ),
changeset_id = int( attributes["changeset"] )
)

def _create_relation_from_attributes(attributes: dict) -> Relation:
visible = None
if attributes.get("visible"):
visible = True if attributes["visible"] == "true" else False
return Relation(
id = int( attributes["id"] ),
visible = visible,
version = int( attributes["version"] ),
timestamp = str( attributes["timestamp"] ),
user_id = int( attributes["uid"] ),
Expand Down
9 changes: 6 additions & 3 deletions tests/api/test_api_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def test_create(self):

@responses.activate
def test_get(self):
should_be = "Node(id = 1, visible = None, version = 110, changeset_id = 232293, timestamp = 2022-02-22T11:31:20Z, user_id = 12342, tags = {'name': 'ali', 'source': 'local knowledge', 'start_date': '2022', 'traffic_calming': 'hump'}, latitude = 53.7573714, longitude = -0.4465657, )"
self.maxDiff = None
should_be = "Node(id = 1, visible = False, version = 110, changeset_id = 232293, timestamp = 2022-02-22T11:31:20Z, user_id = 12342, tags = {'name': 'ali', 'source': 'local knowledge', 'start_date': '2022', 'traffic_calming': 'hump'}, latitude = 53.7573714, longitude = -0.4465657, )"
body = """<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<node id="1" visible="true" version="110" changeset="232293" timestamp="2022-02-22T11:31:20Z" user="alisvndk88" uid="12342" lat="53.7573714" lon="-0.4465657">
<node id="1" visible="false" version="110" changeset="232293" timestamp="2022-02-22T11:31:20Z" user="alisvndk88" uid="12342" lat="53.7573714" lon="-0.4465657">
<tag k="name" v="ali"/>
<tag k="source" v="local knowledge"/>
<tag k="start_date" v="2022"/>
Expand All @@ -48,7 +49,8 @@ def test_get(self):

@responses.activate
def test_update(self):
should_be = "Node(id = 1, visible = None, version = 1, changeset_id = 232293, timestamp = 2022-02-22T11:31:20Z, user_id = 12342, tags = {'name': 'ali', 'source': 'local knowledge', 'start_date': '2022', 'traffic_calming': 'hump'}, latitude = 1, longitude = -0.4465657, )"
self.maxDiff = None
should_be = "Node(id = 1, visible = True, version = 1, changeset_id = 232293, timestamp = 2022-02-22T11:31:20Z, user_id = 12342, tags = {'name': 'ali', 'source': 'local knowledge', 'start_date': '2022', 'traffic_calming': 'hump'}, latitude = 1, longitude = -0.4465657, )"
body = """<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<node id="1" visible="true" version="1" changeset="232293" timestamp="2022-02-22T11:31:20Z" user="alisvndk88" uid="12342" lat="1" lon="-0.4465657">
<tag k="name" v="ali"/>
Expand Down Expand Up @@ -115,6 +117,7 @@ def test_history(self):
history = api.elements.history(Node, 123)
self.assertEqual(len(history), 4)
self.assertEqual(history[3].user_id, 10688)
self.assertEqual(history[3].visible, True)

@responses.activate
def test_version(self):
Expand Down

0 comments on commit b84b4cb

Please sign in to comment.