Skip to content

Commit

Permalink
feat: add ability to remove a bookmark on an episode
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed May 9, 2023
1 parent 6dc32ac commit 4eb896a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/deezer/resources/episode.py
Expand Up @@ -55,3 +55,11 @@ def add_bookmark(self, offset: int, **kwargs) -> bool:
offset=offset,
**kwargs,
)

def remove_bookmark(self, **kwargs) -> bool:
"""
Removes the bookmark on the episode
:returns: a boolean that tells if the operation was successful
"""
return self.client.request("DELETE", f"episode/{self.id}/bookmark", **kwargs)
56 changes: 56 additions & 0 deletions tests/resources/cassettes/TestEpisode.test_remove_bookmark.yaml
@@ -0,0 +1,56 @@
interactions:
- request:
body: null
headers:
Accept:
- "*/*"
Accept-Encoding:
- identity
Connection:
- keep-alive
Content-Length:
- "0"
User-Agent:
- python-requests/2.30.0
method: DELETE
uri: https://api.deezer.com/episode/343457312/bookmark?access_token=dummy
response:
body:
string: '{"error":[],"results":true}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- X-Requested-With, Content-Type, Authorization, Origin, Accept, Accept-Encoding
Access-Control-Allow-Methods:
- POST, GET, OPTIONS, DELETE, PUT
Access-Control-Expose-Headers:
- Location
Access-Control-Max-Age:
- "86400"
Cache-Control:
- no-store, no-cache, must-revalidate
Connection:
- keep-alive
Content-Length:
- "27"
Content-Type:
- application/json; charset=utf-8
Expires:
- Thu, 19 Nov 1981 08:52:00 GMT
Pragma:
- no-cache
Server:
- Apache
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
X-Host:
- blm-web-171
x-org:
- FR
status:
code: 200
message: OK
version: 1
11 changes: 11 additions & 0 deletions tests/resources/test_episode.py
Expand Up @@ -55,3 +55,14 @@ def test_add_bookmark(self, client_token):
)
result = episode.add_bookmark(55)
assert result is True

def test_remove_bookmark(self, client_token):
episode = deezer.Episode(
client_token,
json={
"id": 343457312,
"type": "episode",
},
)
result = episode.remove_bookmark()
assert result is True

0 comments on commit 4eb896a

Please sign in to comment.