-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdf_es_tagging_test.py
50 lines (42 loc) · 1.74 KB
/
df_es_tagging_test.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ***************************************************************************80**************************************120
#
# Set of pytest df_es_tagging.py tests
#
# ***************************************************************************80**************************************120
import df_es_tagging
import pandas
def setup():
config = df_es_tagging.validate_agent_directory("./workspaces/df/es/priorities")
intents = df_es_tagging.load_intents(config["intent_dir"])
return pandas.json_normalize(intents)
def test_df_shape():
df = setup()
assert(isinstance(df,pandas.DataFrame))
assert(df.shape[0]==12)
assert(df.shape[1]==15)
columns = df.columns.to_list()
assert(columns == ['id', 'name', 'auto', 'contexts', 'responses', 'priority',
'webhookUsed', 'webhookForSlotFilling', 'fallbackIntent', 'events',
'conditionalResponses', 'condition', 'conditionalFollowupEvents',
'parentId', 'rootParentId']
)
def test_intent_types():
df = setup()
df = df_es_tagging.process_intent_types(df)
intent_types = df[["intent_type","name"]].groupby("intent_type").count()
print(intent_types)
assert(intent_types.loc["context","name"]==2)
assert(intent_types.loc["follow_on","name"]==2)
assert(intent_types.loc["top_level","name"]==8)
def test_priorities():
df = setup()
df = df_es_tagging.process_priorities(df)
priorities = df[["priority","name"]].groupby("priority").count()
print(priorities)
assert(priorities.loc["highest","name"]==1)
assert(priorities.loc["high","name"]==1)
assert(priorities.loc["normal","name"]==8)
assert(priorities.loc["low","name"]==1)
assert(priorities.loc["ignore","name"]==1)