Exemplo n.º 1
0
def test_interventions_error():

    for filename in filenames:
        chat = WhatsAppChat.from_txt(filename)
        with pytest.raises(ValueError):
            counts = interventions(chat, date_mode='error', msg_length=False)
        with pytest.raises(ValueError):
            counts = interventions(chat, date_mode='error', msg_length=True)
Exemplo n.º 2
0
def test_vis():
    for filename in filenames:
        chat = WhatsAppChat.from_txt(filename)
        counts = interventions(chat=chat, date_mode='date', msg_length=False)
        counts_cumsum = counts.cumsum() 
        fig = vis(counts_cumsum, 'cumulative number of messages sent per day')
        assert isinstance(fig, dict)
        assert ('data' in fig and 'layout' in fig)
Exemplo n.º 3
0
def test_interventions_month_msg_length():

    for filename in filenames:
        chat = WhatsAppChat.from_txt(filename)
        counts = interventions(chat, date_mode='month', msg_length=False)

        assert (isinstance(counts, pd.DataFrame))
        # Asswert chat df and counts df have same users
        assert (set(chat.users) == set(counts.columns))

        # Check range hours
        assert (counts.index.max() == chat.df.index.month.max())
        assert (counts.index.min() == chat.df.index.month.min())
Exemplo n.º 4
0
def test_interventions_date_msg_length():

    for filename in filenames:
        chat = WhatsAppChat.from_txt(filename)
        counts = interventions(chat, date_mode='date', msg_length=True)

        assert (isinstance(counts, pd.DataFrame))
        # Asswert chat df and counts df have same users
        assert (set(chat.users) == set(counts.columns))

        # Assert chat df and counts df have same date window
        assert (chat.df.index.max().date() == counts.index.max().date())
        assert (chat.df.index.min().date() == counts.index.min().date())
Exemplo n.º 5
0
def test_interventions_hourweekday_msg_length():

    for filename in filenames:
        chat = WhatsAppChat.from_txt(filename)
        counts = interventions(chat, date_mode='hourweekday', msg_length=True)

        assert (isinstance(counts, pd.DataFrame))
        # Asswert chat df and counts df have same users
        assert (set(chat.users) == set(counts.columns))

        # Check range days
        assert (counts.index.levels[0].max() == chat.df.index.weekday.max())
        assert (counts.index.levels[0].min() == chat.df.index.weekday.min())

        # Check range hours
        assert (counts.index.levels[1].max() == chat.df.index.hour.max())
        assert (counts.index.levels[1].min() == chat.df.index.hour.min())