Skip to content

Commit

Permalink
Merge pull request #21 from docentYT/development
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
docentYT authored Sep 6, 2023
2 parents 5cf730a + 6fde621 commit aabc108
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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).

## [2.1.0]
#### Added
- `TooManyRequests` exception.
- Support for `429` status code in `api.changeset.discussion.comment()`.

## [2.0.0]
### Added
- Missing status code handling in `notes.get()`.
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 = "2.0.0"
VERSION = "2.1.0"

from .data_classes import *
from .diff import Diff, Frequency
Expand Down
1 change: 1 addition & 0 deletions src/osm_easy_api/api/endpoints/changeset_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def comment(self, changeset_id: int, text: str) -> None:
match response.status_code:
case 200: pass
case 409: raise exceptions.ChangesetNotClosed()
case 429: raise exceptions.TooManyRequests()
case _: assert False, f"Unexpected response status code {response.status_code}. Please report it on github." # pragma: no cover

def subscribe(self, changeset_id: int) -> None:
Expand Down
3 changes: 3 additions & 0 deletions src/osm_easy_api/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ class NoteAlreadyClosed(Exception):
pass

class NoteAlreadyOpen(Exception):
pass

class TooManyRequests(Exception):
pass
24 changes: 24 additions & 0 deletions tests/api/test_api_changeset_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@

class TestApiChangesetDiscussion(unittest.TestCase):

@responses.activate
def test_comment(self):
responses.add(**{
"method": responses.POST,
"url": "https://test.pl/api/0.6/changeset/111/comment?text=Hello%20World",
"status": 200
})

api = Api("https://test.pl", LOGIN, PASSWORD)
def comment(): return api.changeset.discussion.comment(111, "Hello World")
comment()
responses.add(**{
"method": responses.POST,
"url": "https://test.pl/api/0.6/changeset/111/comment?text=Hello%20World",
"status": 409
})
self.assertRaises(ApiExceptions.ChangesetNotClosed, comment)
responses.add(**{
"method": responses.POST,
"url": "https://test.pl/api/0.6/changeset/111/comment?text=Hello%20World",
"status": 429
})
self.assertRaises(ApiExceptions.TooManyRequests, comment)

@responses.activate
def test_subscribe_unsubscribe(self):
responses.add(**{
Expand Down

0 comments on commit aabc108

Please sign in to comment.