-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
test_figures.py
72 lines (52 loc) · 1.84 KB
/
test_figures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pytest
from whatstk.graph.base import FigureBuilder
from whatstk.whatsapp.objects import WhatsAppChat
import plotly.graph_objs as go
filename = "./tests/chats/hformats/[%d.%m.%y_%I:%M:%S_%p]_%name:.txt"
def load_chat_as_df():
return WhatsAppChat.from_source(filename).df
def load_chat():
return WhatsAppChat.from_source(filename)
def test_init():
df = load_chat_as_df()
_ = FigureBuilder(df=df)
chat = load_chat()
_ = FigureBuilder(chat=chat)
with pytest.raises(ValueError):
_ = FigureBuilder()
def test_init_mapping_dict_1():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
mapping = fb.user_color_mapping
assert(isinstance(fb.user_color_mapping, dict))
assert(len(mapping) == df['username'].nunique())
def test_init_mapping_dict_2():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
value = {'a': 'b'}
fb.user_color_mapping = value
assert(fb.user_color_mapping == value)
def test_user_msg_length_boxplot():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
fig = fb.user_msg_length_boxplot()
assert isinstance(fig, go.Figure)
assert ('data' in fig and 'layout' in fig)
def test_user_interventions_count_linechart():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
fig = fb.user_interventions_count_linechart()
assert isinstance(fig, go.Figure)
assert ('data' in fig and 'layout' in fig)
def test_user_message_responses_flow():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
fig = fb.user_message_responses_flow()
assert isinstance(fig, go.Figure)
assert ('data' in fig and 'layout' in fig)
def test_user_message_responses_heatmap():
df = load_chat_as_df()
fb = FigureBuilder(df=df)
fig = fb.user_message_responses_heatmap()
assert isinstance(fig, go.Figure)
assert ('data' in fig and 'layout' in fig)