Beispiel #1
0
def _add_online_status_columns(df: pd.DataFrame) -> pd.DataFrame:
    """Adds string and unicode online status columns to a dataframe of clients.

  Args:
    df: Dataframe of clients.

  Returns:
    Dataframe with columns added.
  """
    if 'last_seen_at' not in df.columns:
        return df

    statuses = [client_textify.online_status(tm) for tm in df['last_seen_at']]
    icons = [client_textify.online_icon(tm) for tm in df['last_seen_at']]
    df.insert(0, 'online', pd.Series(statuses))
    df.insert(0, 'online.pretty', pd.Series(icons))
    return df
Beispiel #2
0
    def testOffline(self):
        current_time_secs = 1560000000
        last_seen_at = (current_time_secs - 4 * 60 * 60 * 24) * (10**6)

        with mock.patch.object(time, 'time', return_value=current_time_secs):
            self.assertEqual(client.online_status(last_seen_at), 'offline')
Beispiel #3
0
    def testSeen1d(self):
        current_time_secs = 1560000000
        last_seen_at = (current_time_secs - 3 * 60 * 60) * (10**6)

        with mock.patch.object(time, 'time', return_value=current_time_secs):
            self.assertEqual(client.online_status(last_seen_at), 'seen-1d')