mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Handle absence of notification in 'notifications' command
This commit is contained in:
parent
6360e4d07d
commit
204d4d4138
@ -545,6 +545,20 @@ def test_notifications(mock_get, capsys):
|
||||
"",
|
||||
])
|
||||
|
||||
@mock.patch('toot.http.get')
|
||||
def test_notifications_empty(mock_get, capsys):
|
||||
mock_get.return_value = MockResponse([])
|
||||
|
||||
console.run_command(app, user, 'notifications', [])
|
||||
|
||||
mock_get.assert_called_once_with(app, user, '/api/v1/notifications')
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
out = uncolorize(out)
|
||||
|
||||
assert not err
|
||||
assert out == "No notification\n"
|
||||
|
||||
|
||||
@mock.patch('toot.http.post')
|
||||
def test_notifications_clear(mock_post, capsys):
|
||||
|
@ -304,8 +304,13 @@ def notifications(app, user, args):
|
||||
print_out("<green>Cleared notifications</green>")
|
||||
return
|
||||
|
||||
notifications = api.get_notifications(app, user)
|
||||
if not notifications:
|
||||
print_out("<yellow>No notification</yellow>")
|
||||
return
|
||||
|
||||
width = 100
|
||||
for notification in sorted(api.get_notifications(app, user),
|
||||
for notification in sorted(notifications,
|
||||
key=lambda n: datetime.strptime(
|
||||
n["created_at"], "%Y-%m-%dT%H:%M:%S.%fZ"),
|
||||
reverse=True):
|
||||
|
Loading…
Reference in New Issue
Block a user