Skip to content

Commit

Permalink
fix: use response status_code instead of status
Browse files Browse the repository at this point in the history
  • Loading branch information
lenkan committed Nov 7, 2023
1 parent ba43e15 commit bef9816
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/signify/app/notifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def markAsRead(self, nid):
"""
res = self.client.put(f"/notifications/{nid}", json={})
return res.status == 202
return res.status_code == 202

def delete(self, nid):
""" Delete notification
Expand All @@ -56,6 +56,4 @@ def delete(self, nid):
"""
res = self.client.delete(path=f"/notifications/{nid}")
# TODO: Figure out why res doesn't have status??
# return res.status == 202
return True
return res.status_code == 202
10 changes: 5 additions & 5 deletions tests/app/test_notifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def test_noticiation_mark_as_read():
notes = Notifications(client=mock_client) # type: ignore

from requests import Response
mock_response = mock({'status': 202}, spec=Response, strict=True)
mock_response = mock({'status_code': 202}, spec=Response, strict=True)
expect(mock_client, times=1).put('/notifications/ABC123', json={}).thenReturn(mock_response)

out = notes.markAsRead(nid="ABC123")
assert out is True

mock_response = mock({'status': 404}, spec=Response, strict=True)
mock_response = mock({'status_code': 404}, spec=Response, strict=True)
expect(mock_client, times=1).put('/notifications/DEF456', json={}).thenReturn(mock_response)

out = notes.markAsRead(nid="DEF456")
Expand All @@ -65,17 +65,17 @@ def test_noticiation_delete():
notes = Notifications(client=mock_client) # type: ignore

from requests import Response
mock_response = mock({'status': 202}, spec=Response, strict=True)
mock_response = mock({'status_code': 202}, spec=Response, strict=True)
expect(mock_client, times=1).delete(path='/notifications/ABC123').thenReturn(mock_response)

out = notes.delete(nid="ABC123")
assert out is True

mock_response = mock({'status': 404}, spec=Response, strict=True)
mock_response = mock({'status_code': 404}, spec=Response, strict=True)
expect(mock_client, times=1).delete(path='/notifications/DEF456').thenReturn(mock_response)

out = notes.delete(nid="DEF456")
assert out is True
assert out is False

verifyNoUnwantedInteractions()
unstub()

0 comments on commit bef9816

Please sign in to comment.