-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: User's last activity status improved.
Last activity improvements: - Currently a user's last activity is represented by a datetime object. A function is added that returns a user's last activity in words, e.g, '1 hour ago', '3 days ago'. - All timestamps before 2 weeks are returned as 'more than 2 weeks ago'. The above two points ensure equivalence with webapp. Test added (user presence status). Fixes #511.
- Loading branch information
1 parent
dfcfe88
commit af34576
Showing
2 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from datetime import datetime, timedelta | ||
from platform import platform | ||
from typing import Any | ||
|
||
|
@@ -283,6 +284,36 @@ def test_stream_muting_confirmation_popup(self, mocker, controller, | |
+ "' ?"), "center") | ||
pop_up.assert_called_once_with(controller, text(), partial()) | ||
|
||
@pytest.mark.parametrize('presence, time_in_sec, expected_status', [ | ||
('active', 0, 'Active now'), | ||
('idle', 10, 'Just now'), | ||
('idle', 100, '1 minute ago'), | ||
('idle', 150, '2 minutes ago'), | ||
('idle', 10000, '2 hours ago'), | ||
('idle', 200000, '2 days ago'), | ||
('offline', 2000000, 'More than 2 weeks ago'), | ||
], ids=[ | ||
'active_now', 'active_few_seconds_ago', | ||
'active_one_minute_ago', 'active_few_minutes_ago', | ||
'active_few_hours_ago', 'active_few_days_ago', | ||
'active_more_than_two_weeks_ago' | ||
]) | ||
def test_get_user_presence_status(self, presence, controller, mocker, | ||
time_in_sec, expected_status): | ||
|
||
def get_user_presence(email: str): | ||
data = {'presence': {}} | ||
data['presence']['aggregated'] = { | ||
'status': presence, | ||
'timestamp': (datetime.timestamp(datetime.now() | ||
- timedelta(seconds=time_in_sec))), | ||
} | ||
return data | ||
controller.client.get_user_presence = get_user_presence | ||
|
||
assert (controller.get_user_presence_status('[email protected]') | ||
== expected_status) | ||
|
||
@pytest.mark.parametrize('initial_narrow, final_narrow', [ | ||
([], [['search', 'FOO']]), | ||
([['search', 'BOO']], [['search', 'FOO']]), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters