def test_status_no_event_time(mock_client, mock_reader): with mock.patch("bot.activity.datetime") as mock_datetime: # Mock `datetime.utcnow`, but retain the original datetime class functionality through the `side_effect` attribute. mock_datetime.utcnow.return_value = timestamp.from_string( "2020-01-01 00:00:31") mock_datetime.side_effect = datetime assert get_status(mock_client, mock_reader) == Status.do_not_disturb
def test_status_not_ready(mock_client, mock_reader): mock_client.is_ready = lambda: False with mock.patch("bot.activity.datetime") as mock_datetime: mock_datetime.utcnow.return_value = timestamp.from_string( "2020-01-01 00:00:00") mock_datetime.side_effect = datetime assert get_status(mock_client, mock_reader) == Status.do_not_disturb
def test_status_idle(mock_client, mock_reader): mock_reader.latest_event_time = timestamp.from_string( "2020-01-01 00:00:00") with mock.patch("bot.activity.datetime") as mock_datetime: mock_datetime.utcnow.return_value = timestamp.from_string( "2020-01-01 00:30:01") mock_datetime.side_effect = datetime assert get_status(mock_client, mock_reader) == Status.idle