Skip to content

Commit ebb7409

Browse files
committed
Handle alternate 'has been cancelled' text in Telstra notifications
1 parent 6c93c08 commit ebb7409

File tree

4 files changed

+235
-6
lines changed

4 files changed

+235
-6
lines changed

circuit_maintenance_parser/parsers/telstra.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ def parse_html(self, soup):
2222
self.parse_tables(soup.find_all("table"), data)
2323
return [data]
2424

25-
def parse_tables(self, tables: ResultSet, data: Dict):
25+
def parse_tables(self, tables: ResultSet, data: Dict): # pylint: disable=too-many-locals
2626
"""Parse Table tag."""
2727
for table in tables:
2828
for td_element in table.find_all("td"):
2929
# TODO: We should find a more consistent way to parse the status of a maintenance note
30-
if "maintenance has been scheduled" in td_element.text.lower():
30+
td_text = td_element.text.lower()
31+
if "maintenance has been scheduled" in td_text:
3132
data["status"] = Status("CONFIRMED")
32-
elif "this is a reminder notification to notify that a planned maintenance" in td_element.text.lower():
33+
elif "this is a reminder notification to notify that a planned maintenance" in td_text:
3334
data["status"] = Status("CONFIRMED")
34-
elif "has been completed" in td_element.text.lower():
35+
elif "has been completed" in td_text:
3536
data["status"] = Status("COMPLETED")
36-
elif "has been amended" in td_element.text.lower():
37+
elif "has been amended" in td_text:
3738
data["status"] = Status("RE-SCHEDULED")
38-
elif "has been withdrawn" in td_element.text.lower():
39+
elif "has been withdrawn" in td_text or "has been cancelled" in td_text:
3940
data["status"] = Status("CANCELLED")
4041
else:
4142
continue
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8">
5+
<title>Maintenance - Telstra</title>
6+
<style type=3D"text/css">
7+
outlook a {
8+
padding: 0;
9+
}
10+
body {
11+
background: #FFF;
12+
width: 100% !important;
13+
-webkit-text-size-adjust: 100%;
14+
-ms-text-size-adjust: 100%;
15+
margin: 0;
16+
padding: 0;
17+
font-family: Arial, Helvetica, sans-serif;
18+
}
19+
td { }
20+
p { margin-top: 0.7em; margin-bottom: 0.7em; }
21+
ul { margin: 0; padding: 0 0 0 15px; list-style-type: disc; }
22+
li { padding: 0px; margin: 0 0 0.4em; }
23+
a { color: #B32034; text-decoration: none; }
24+
img { border: 0; }
25+
hr { clear: both; background-color: #CCC; border: none; color: #CCC; height=
26+
: 1px; margin: 1em 0; }
27+
</style>
28+
</head>
29+
30+
<body style=3D"background: #FFF;width: 100% !important;-webkit-text-size-ad=
31+
just: 100%;-ms-text-size-adjust: 100%;margin: 0;padding: 0;font-family: Ari=
32+
al, Helvetica, sans-serif">
33+
<table cellpadding=3D"0" cellspacing=3D"0" border=3D"0" width=3D"600" align=
34+
=3D"center" style=3D"margin: 0 auto;padding: 0;width: 600px !important;line=
35+
-height: 100% !important;background: #FFF">
36+
<tr>
37+
<td>
38+
<table width=3D"600" border=3D"0" cellpadding=3D"15" cellspacing=3D"0=
39+
" style=3D"background: #EEE">
40+
<tr>
41+
<td><table cellpadding=3D"0" cellspacing=3D"0" border=3D"0" align=
42+
=3D"center" width=3D"570" style=3D"background: #FFF;width: 570px;margin: 0 =
43+
auto">
44+
<td valign=3D"top"><img src=3D"https://www.telstraglobal.com/upload_fil=
45+
es/banner_notification_OM.png" alt=3D"Telstra" width=3D"570" height=3D"180"=
46+
border=3D"0" style=3D"border: 0; display: block;"/></td>
47+
<tr><td>
48+
<table width=3D510 border=3D0 bordercolor=3Dred cellspacing=3D"5" =
49+
align=3D"center" >
50+
<tr style=3D"font-family: Arial, Helvetica, sans-serif; li=
51+
ne-height: 1.1; font-size:24px; font-weight:bold;color: #B32034; ">
52+
<td style=3D'background: #FFF;' height=3D15>Planned Maint=
53+
enance Cancellation</td>
54+
</tr>
55+
<!--by reejan-->
56+
<tr style=3D"font-family: Arial, Helvetica, sans-serif; line-heigh=
57+
t: 1.1; font-size: 16px; font-weight:bold;color: #B32034; ">
58+
<td style=3D'background: #FFF;' height=3D15>Service Impacti=
59+
ng</td>
60+
</tr>
61+
<tr style=3D"font-family: Arial, Helvetica, sans-serif; lin=
62+
e-height: 1.1; font-size: 12px; color: #B32034; ">
63+
<td style=3D'background: #FFF;' height=3D25>Planned Maint=
64+
enance has been cancelled - Please be advised this work was cancelled due t=
65+
o an equipment issue the prevented the work from being completed .</td>
66+
</tr>
67+
</table>
68+
</td></tr>
69+
</tr>
70+
<td valign=3D"top" style=3D"padding: 0 0 30px;">
71+
<table width=3D"510" border=3D"0" align=3D"center" cellpadding=3D"0" ce=
72+
llspacing=3D"0">
73+
<tr>
74+
<td width=3D"510" colspan=3D"2">
75+
<table width=3D"100%" border=3D"0" cellspacing=3D"2" =
76+
style=3D"font-family: Arial, Helvetica, sans-serif; line-height: 1.1; font-=
77+
size: 11px; color: #000000;">
78+
<br/>
79+
<tr>
80+
<th width=3D"37%" align=3D"left" valign=3D"top" s=
81+
tyle=3D" font-size: 12px; font-weight: bold;"></th>
82+
<td width=3D"63%" valign=3D"top" ></td>
83+
</tr>
84+
<tr>
85+
<th width=3D"37%" align=3D"left" valign=3D"top" s=
86+
tyle=3D" font-size: 12px; font-weight: bold;">To: </th>
87+
<td width=3D"63%" valign=3D"top" >Customer Name</td>
88+
</tr>
89+
<tr>
90+
<th align=3D"left" valign=3D"top" style=3D"f=
91+
ont-size: 12px; font-weight: bold;">Attention: </th>
92+
<td valign=3D"top" style=3D"max-width: 100px; wor=
93+
d-break: break-all;">jhamie villaroman ,amir,jason,chris,nicole ho,donna tu=
94+
rner,rd notices,noc</td>
95+
</tr>
96+
<tr><td width=3D25>&nbsp;</td></tr>
97+
<tr>
98+
<th align=3D"left" valign=3D"top" style=3D"font-s=
99+
ize: 12px; font-weight: bold;">Email :</th>
100+
<td valign=3D"top" style=3D"max-width: 100px; wor=
101+
d-break: break-all;text-decoration:none;"><font style=3D"display: none">@</=
102+
103+
104+
105+
</tr>
106+
<tr><td width=3D25>&nbsp;</td></tr>
107+
<tr>
108+
<th align=3D"left" valign=3D"top" style=3D"font-s=
109+
ize: 12px; font-weight: bold;">Change Reference: </th>
110+
<td valign=3D"top" >PN123456</td>
111+
</tr>
112+
<tr><td width=3D25>&nbsp;</td></tr>
113+
<tr>
114+
<th align=3D"left" valign=3D"top" style=3D"font-s=
115+
ize: 12px; font-weight: bold;">Maintenance Window: </th>
116+
<td valign=3D"top" >13-Dec-2021 12:00:00(UTC) to =
117+
13-Dec-2021 13:29:00(UTC)</td>
118+
</tr>
119+
<tr>
120+
<th align=3D"left" valign=3D"top" style=3D"font-s=
121+
ize: 12px; font-weight: bold;">Expected Impact: </th>
122+
<td valign=3D"top" >1 hour 29 minutes outage with=
123+
in the change window</td>
124+
</tr>
125+
<tr><td width=3D25>&nbsp;</td></tr>
126+
<tr colspan=3D2>
127+
<th align=3D"left" valign=3D"top" style=3D"font-s=
128+
ize: 12px; font-weight: bold;">Maintenance Details:</th>
129+
</tr>
130+
<tr><td width=3D25>&nbsp;</td></tr>
131+
<tr>
132+
<td align=3D"left" colspan=3D"2" valign=3D"top" s=
133+
tyle=3D"font-size: 12px; ">Telstra Corporation Essential Change Notificatio=
134+
n - CMART 3513026</td>
135+
136+
</tr>
137+
<tr><td width=3D25>&nbsp;</td></tr>
138+
<tr>
139+
<td align=3D"left" colspan=3D"2" valign=3D"top" s=
140+
tyle=3D"font-size: 12px; ">Telstra Corporation will implement maintenance w=
141+
ork in Australia due to planned hardware replacement work.
142+
Your service(s) may experience a break to service during the change window.
143+
***At this current time, your link will be down during this maintenance and=
144+
current cable fault AAG Segment 1i (Hongkong -BU4). Please contact our ser=
145+
vice desk [[email protected]] if necessary***</td>
146+
147+
</tr>
148+
<tr><td width=3D25>&nbsp;</td></tr>
149+
<tr>
150+
<th align=3D"left" valign=3D"top" style=3D"font-s=
151+
ize: 12px; font-weight: bold;">Service(s) Impacted:</th>
152+
<td valign=3D"top" >SNG SYD EPL 9875643<br></td>
153+
</tr>
154+
<tr>
155+
<td width=3D25>&nbsp;</td>
156+
</tr>
157+
<tr>
158+
<td colspan=3D"2"align=3D"left" valign=3D"top" =
159+
style=3D"color: #000000;font-size: 12px; "> <a href=3D"mailto:[email protected]=
160+
stra.com?subject=3DQuery- Telstra Planned Maintenance - Service Impacting -=
161+
PN123456"
162+
style=3D"color: #FF7F50;"><u>Click here</u></a> If you have any que=
163+
stions, comments or concerns regarding this maintenance activity or telepho=
164+
ne Global 800: +800 8448 8888* or Direct: +852 3192 7420 </td>
165+
166+
</tr>
167+
<tr>
168+
<td width=3D25>&nbsp;</td>
169+
</tr>
170+
<tr>
171+
<td colspan=3D"2"align=3D"left" valign=3D"top" style=3D"color: #00=
172+
0000; font-size: 12px; "><a href=3D"https://connectapp.telstra.com/"
173+
style=3D"color: #FF7F50;"><u>Click here</u></a> for immediate infor=
174+
mation on planned maintenance or viewing your historical planned maintenanc=
175+
e tickets details via our Telstra Connect Portal using your email ID as log=
176+
in.</td>
177+
</tr>
178+
<tr>
179+
<td width=3D25>&nbsp;</td>
180+
</tr>
181+
<tr>
182+
<td colspan=3D"2"align=3D"left" valign=3D"top" s=
183+
tyle=3D"color: #000000; font-size: 12px; ">
184+
<a href=3D"mailto:[email protected]?subject=3DUpdate contact de=
185+
tails- Telstra Planned Maintenance - Service Impacting - PN123456
186+
&body=3DHi Change Management team,%0D%0A %0D%0AI would like to updat=
187+
e my personal contact information as below:%0D%0A Email id:%0D%0A =
188+
Contact number:"
189+
style=3D"color: #FF7F50;"><u>Click here</u> </a> to email us about a=
190+
ny updates to your contact details or requesting access to Telstra Connect =
191+
Portal.
192+
</td>
193+
</tr>
194+
</table>
195+
</td>
196+
</tr>
197+
</table></td>
198+
</tr>
199+
</table></td>
200+
</tr>
201+
</table>
202+
203+
</td>
204+
</tr>
205+
</table>
206+
</body>
207+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"account": "Customer Name",
4+
"circuits": [
5+
{
6+
"circuit_id": "SNG SYD EPL 9875643",
7+
"impact": "OUTAGE"
8+
}
9+
],
10+
"end": 1639402140,
11+
"maintenance_id": "PN123456",
12+
"start": 1639396800,
13+
"status": "CANCELLED",
14+
"summary": "Telstra Corporation Essential Change Notification - CMART 3513026. Telstra Corporation will implement maintenance work in Australia due to planned hardware replacement work.\r\nYour service(s) may experience a break to service during the change window.\r\n***At this current time, your link will be down during this maintenance and current cable fault AAG Segment 1i (Hongkong -BU4). Please contact our service desk [[email protected]] if necessary***"
15+
}
16+
]

tests/unit/test_parsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@
284284
Path(dir_path, "data", "telstra", "telstra6.html"),
285285
Path(dir_path, "data", "telstra", "telstra6_result.json"),
286286
),
287+
(
288+
HtmlParserTelstra1,
289+
Path(dir_path, "data", "telstra", "telstra7.html"),
290+
Path(dir_path, "data", "telstra", "telstra7_result.json"),
291+
),
287292
# Turkcell
288293
(
289294
HtmlParserTurkcell1,

0 commit comments

Comments
 (0)