Skip to content

Commit

Permalink
feat: added APIs for get_event and delete_event
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Mar 3, 2022
1 parent c5df050 commit 32c25fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions aw_client/client.py
Expand Up @@ -135,6 +135,23 @@ def get_info(self):
# Event get/post requests
#

def get_event(
self,
bucket_id: str,
event_id: int,
) -> Event:
endpoint = f"buckets/{bucket_id}/events/{event_id}"
event = self._get(endpoint).json()
return Event(**event)

def delete_event(
self,
bucket_id: str,
event_id: int,
) -> None:
endpoint = f"buckets/{bucket_id}/events/{event_id}"
self._delete(endpoint).json()

def get_events(
self,
bucket_id: str,
Expand Down
9 changes: 9 additions & 0 deletions tests/test_client.py
Expand Up @@ -73,6 +73,15 @@ def test_full():
assert len(result) == 1
assert len(result[0]) == 3

# Get single event
e = client.get_event(bucket_name, fetched_events[1].id)
assert e.id == fetched_events[1].id

# Delete single event
client.delete_event(bucket_name, fetched_events[1].id)
with pytest.raises(ValueError):
client.get_event(bucket_name, fetched_events[1].id)

# Test exception raising
with pytest.raises(ValueError):
# timeperiod end time does not have a timezone set
Expand Down

0 comments on commit 32c25fd

Please sign in to comment.