-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_slack_bot.py
85 lines (73 loc) · 2.63 KB
/
test_slack_bot.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
73
74
75
76
77
78
79
80
81
82
83
84
85
import json
from typing import Dict
from slack_bot import CovidSlackBot
def test_generate_message_for_code():
with open("./resources/nsw.json") as file:
nsw_data: Dict = json.load(file)
slack_bot: CovidSlackBot = CovidSlackBot(
"Fake Token Here",
"Channel Name Here",
"CovidLiveSummary",
":robot_face:",
)
message = slack_bot.generate_message_for_code(nsw_data)
expected = """--- *Latest COVID figures for NSW* ---
:helmet_with_white_cross: 1,102 New total cases | 19,040 active cases (+1,041)
:earth_asia: 2 New overseas cases
:hospital: 908 (+39) Hospitalised | 150 (+7) in ICU | 66 (+8) ventilated
:skull: +4 Deaths | 154 Total COVID Deaths
:test_tube: +173,913 Tests in the last reporting period | 13,367,758 total tests
:syringe: 6,990,810 doses (+121,170) | 69.3% (+1.1) 16+ 1st dose | 37.8% (+0.77) 16+ 2nd dose
(This will often be lagging as GP numbers come in at odd times)
:robot_face: 2021-09-01 Report, using covidlive.com.au
Data published at: 2021-09-01 11:15:06 AEST"""
assert message == expected, f"Message: message should match expected"
def test_generate_vax_data_for_code():
with open("./resources/nsw.json") as file:
nsw_data: Dict = json.load(file)
slack_bot: CovidSlackBot = CovidSlackBot(
"Fake Token Here",
"Channel Name Here",
"CovidLiveSummary",
":robot_face:",
)
stats = slack_bot.generate_vax_stats_for_code(nsw_data)
expected = [
{
'type': 'section',
'text':
{
'type': 'mrkdwn',
'text': ':none: *NSW*\n'
}
},
{
'type': 'context',
'elements': [
{
'type': 'mrkdwn',
'text': '*6,990,810* total doses administered. Data published at 2021-09-01 11:15:06 AEST'
}
]
},
{
'type': 'divider'
},
{
'type': 'section',
'fields': [
{
'type': 'mrkdwn',
'text': '\n :syringe: *1st dose* (16+)\n *60%:* :white_check_mark:\n *70%:* Sep 02\n *80%:* Sep 11\n *90%:* Sep 20'
},
{
'type': 'mrkdwn',
'text': '\n :syringe::syringe: *2nd dose* (16+)\n *60%:* Sep 30\n *70%:* Oct 13\n *80%:* Oct 26\n *90%:* Nov 08'
}
]
},
{
'type': 'divider'
}
]
assert stats == expected, f"Message: stats should match expected"