Skip to content

Commit 956c049

Browse files
authored
Add iCal parsing to GTT (for EXA related maintenance) (#273)
* Add new EXA parser to separate from GTT * Add iCal parser to GTT and remove EXA * Fix linter issue * Update ical include_filter GTT * Fix linter issues
1 parent 89bdcc9 commit 956c049

File tree

7 files changed

+116
-1
lines changed

7 files changed

+116
-1
lines changed

circuit_maintenance_parser/provider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,13 @@ class GTT(GenericProvider):
307307
"""EXA (formerly GTT) provider custom class."""
308308

309309
# "Planned Work Notification", "Emergency Work Notification"
310-
_include_filter = PrivateAttr({EMAIL_HEADER_SUBJECT: ["Work Notification"]})
310+
_include_filter = PrivateAttr(
311+
{"Icalendar": ["BEGIN"], "ical": ["BEGIN"], EMAIL_HEADER_SUBJECT: ["Work Notification"]}
312+
)
311313

312314
_processors: List[GenericProcessor] = PrivateAttr(
313315
[
316+
SimpleProcessor(data_parsers=[ICal]),
314317
CombinedProcessor(data_parsers=[EmailDateParser, HtmlParserGTT1]),
315318
]
316319
)

tests/unit/data/gtt/gtt8

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
BEGIN:VCALENDAR
2+
VERSION:2.0
3+
PRODID:EXA
4+
BEGIN:VEVENT
5+
UID:00123456
6+
DTSTART;VALUE=DATE-TIME:20240306T190000Z
7+
SEQUENCE:1
8+
TRANSP:OPAQUE
9+
DTEND;VALUE=DATE-TIME:20240307T060000Z
10+
SUMMARY:EXA TT#(00123456)\ Planned Work
11+
CLASS:PUBLIC
12+
ORGANIZER;CN="EXAInfra":mailto:akanksha.ambastha@exainfra.net
13+
DTSTAMP;VALUE=DATE-TIME:20240208T000000Z
14+
X-MAINTNOTE-PROVIDER:EXA Infrastructure
15+
X-MAINTNOTE-ACCOUNT:Test Account
16+
X-MAINTNOTE-MAINTENANCE-ID:00123456
17+
X-MAINTNOTE-OBJECT-ID:TEST/WAVE/123456
18+
X-MAINTNOTE-IMPACT:OUTAGE
19+
X-MAINTNOTE-STATUS:CONFIRMED
20+
END:VEVENT
21+
END:VCALENDAR

tests/unit/data/gtt/gtt8_result.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{
3+
"account": "Test Account",
4+
"circuits": [
5+
{
6+
"circuit_id": "TEST/WAVE/123456",
7+
"impact": "OUTAGE"
8+
}
9+
],
10+
"end": 1709791200,
11+
"maintenance_id": "00123456",
12+
"organizer": "mailto:akanksha.ambastha@exainfra.net",
13+
"provider": "EXA Infrastructure ",
14+
"sequence": 1,
15+
"stamp": 1707350400,
16+
"start": 1709751600,
17+
"status": "CONFIRMED",
18+
"summary": "EXA TT#(00123456)\\ Planned Work",
19+
"uid": "00123456"
20+
}
21+
]

tests/unit/data/gtt/gtt9

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
BEGIN:VCALENDAR
2+
VERSION:2.0
3+
PRODID:EXA
4+
BEGIN:VEVENT
5+
UID:00223456
6+
DTSTART;VALUE=DATE-TIME:20240306T190000Z
7+
SEQUENCE:1
8+
TRANSP:OPAQUE
9+
DTEND;VALUE=DATE-TIME:20240307T060000Z
10+
SUMMARY:EXA TT#(00223456)\ Planned Work
11+
CLASS:PUBLIC
12+
ORGANIZER;CN="EXAInfra":mailto:akanksha.ambastha@exainfra.net
13+
DTSTAMP;VALUE=DATE-TIME:20240208T000000Z
14+
X-MAINTNOTE-PROVIDER:EXA Infrastructure
15+
X-MAINTNOTE-ACCOUNT:Test Account
16+
X-MAINTNOTE-MAINTENANCE-ID:00223456
17+
X-MAINTNOTE-OBJECT-ID:TEST/WAVE/123456
18+
X-MAINTNOTE-IMPACT:OUTAGE
19+
X-MAINTNOTE-STATUS:CONFIRMED
20+
END:VEVENT
21+
END:VCALENDAR

tests/unit/data/gtt/gtt9_result.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{
3+
"account": "Test Account",
4+
"circuits": [
5+
{
6+
"circuit_id": "TEST/WAVE/123456",
7+
"impact": "OUTAGE"
8+
}
9+
],
10+
"end": 1709791200,
11+
"maintenance_id": "00223456",
12+
"organizer": "mailto:akanksha.ambastha@exainfra.net",
13+
"provider": "EXA Infrastructure ",
14+
"sequence": 1,
15+
"stamp": 1707350400,
16+
"start": 1709751600,
17+
"status": "CONFIRMED",
18+
"summary": "EXA TT#(00223456)\\ Planned Work",
19+
"uid": "00223456"
20+
}
21+
]

tests/unit/test_e2e.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,24 @@
411411
Path(dir_path, "data", "gtt", "gtt7_result.json"),
412412
],
413413
),
414+
(
415+
GTT,
416+
[
417+
("ical", Path(dir_path, "data", "gtt", "gtt8")),
418+
],
419+
[
420+
Path(dir_path, "data", "gtt", "gtt8_result.json"),
421+
],
422+
),
423+
(
424+
GTT,
425+
[
426+
("ical", Path(dir_path, "data", "gtt", "gtt9")),
427+
],
428+
[
429+
Path(dir_path, "data", "gtt", "gtt9_result.json"),
430+
],
431+
),
414432
# HGC
415433
(
416434
HGC,

tests/unit/test_parsers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,16 @@ def default(self, o):
366366
Path(dir_path, "data", "gtt", "gtt7.eml"),
367367
Path(dir_path, "data", "gtt", "gtt7_html_parser_result.json"),
368368
),
369+
(
370+
ICal,
371+
Path(dir_path, "data", "gtt", "gtt8"),
372+
Path(dir_path, "data", "gtt", "gtt8_result.json"),
373+
),
374+
(
375+
ICal,
376+
Path(dir_path, "data", "gtt", "gtt9"),
377+
Path(dir_path, "data", "gtt", "gtt9_result.json"),
378+
),
369379
# HGC
370380
(
371381
HtmlParserHGC1,

0 commit comments

Comments
 (0)