Skip to content

Commit

Permalink
Add iCal parsing to GTT (for EXA related maintenance) (#273)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aliex-13 authored Mar 15, 2024
1 parent 89bdcc9 commit 956c049
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 1 deletion.
5 changes: 4 additions & 1 deletion circuit_maintenance_parser/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,13 @@ class GTT(GenericProvider):
"""EXA (formerly GTT) provider custom class."""

# "Planned Work Notification", "Emergency Work Notification"
_include_filter = PrivateAttr({EMAIL_HEADER_SUBJECT: ["Work Notification"]})
_include_filter = PrivateAttr(
{"Icalendar": ["BEGIN"], "ical": ["BEGIN"], EMAIL_HEADER_SUBJECT: ["Work Notification"]}
)

_processors: List[GenericProcessor] = PrivateAttr(
[
SimpleProcessor(data_parsers=[ICal]),
CombinedProcessor(data_parsers=[EmailDateParser, HtmlParserGTT1]),
]
)
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/data/gtt/gtt8
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:EXA
BEGIN:VEVENT
UID:00123456
DTSTART;VALUE=DATE-TIME:20240306T190000Z
SEQUENCE:1
TRANSP:OPAQUE
DTEND;VALUE=DATE-TIME:20240307T060000Z
SUMMARY:EXA TT#(00123456)\ Planned Work
CLASS:PUBLIC
ORGANIZER;CN="EXAInfra":mailto:[email protected]
DTSTAMP;VALUE=DATE-TIME:20240208T000000Z
X-MAINTNOTE-PROVIDER:EXA Infrastructure
X-MAINTNOTE-ACCOUNT:Test Account
X-MAINTNOTE-MAINTENANCE-ID:00123456
X-MAINTNOTE-OBJECT-ID:TEST/WAVE/123456
X-MAINTNOTE-IMPACT:OUTAGE
X-MAINTNOTE-STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
21 changes: 21 additions & 0 deletions tests/unit/data/gtt/gtt8_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"account": "Test Account",
"circuits": [
{
"circuit_id": "TEST/WAVE/123456",
"impact": "OUTAGE"
}
],
"end": 1709791200,
"maintenance_id": "00123456",
"organizer": "mailto:[email protected]",
"provider": "EXA Infrastructure ",
"sequence": 1,
"stamp": 1707350400,
"start": 1709751600,
"status": "CONFIRMED",
"summary": "EXA TT#(00123456)\\ Planned Work",
"uid": "00123456"
}
]
21 changes: 21 additions & 0 deletions tests/unit/data/gtt/gtt9
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:EXA
BEGIN:VEVENT
UID:00223456
DTSTART;VALUE=DATE-TIME:20240306T190000Z
SEQUENCE:1
TRANSP:OPAQUE
DTEND;VALUE=DATE-TIME:20240307T060000Z
SUMMARY:EXA TT#(00223456)\ Planned Work
CLASS:PUBLIC
ORGANIZER;CN="EXAInfra":mailto:[email protected]
DTSTAMP;VALUE=DATE-TIME:20240208T000000Z
X-MAINTNOTE-PROVIDER:EXA Infrastructure
X-MAINTNOTE-ACCOUNT:Test Account
X-MAINTNOTE-MAINTENANCE-ID:00223456
X-MAINTNOTE-OBJECT-ID:TEST/WAVE/123456
X-MAINTNOTE-IMPACT:OUTAGE
X-MAINTNOTE-STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
21 changes: 21 additions & 0 deletions tests/unit/data/gtt/gtt9_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"account": "Test Account",
"circuits": [
{
"circuit_id": "TEST/WAVE/123456",
"impact": "OUTAGE"
}
],
"end": 1709791200,
"maintenance_id": "00223456",
"organizer": "mailto:[email protected]",
"provider": "EXA Infrastructure ",
"sequence": 1,
"stamp": 1707350400,
"start": 1709751600,
"status": "CONFIRMED",
"summary": "EXA TT#(00223456)\\ Planned Work",
"uid": "00223456"
}
]
18 changes: 18 additions & 0 deletions tests/unit/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,24 @@
Path(dir_path, "data", "gtt", "gtt7_result.json"),
],
),
(
GTT,
[
("ical", Path(dir_path, "data", "gtt", "gtt8")),
],
[
Path(dir_path, "data", "gtt", "gtt8_result.json"),
],
),
(
GTT,
[
("ical", Path(dir_path, "data", "gtt", "gtt9")),
],
[
Path(dir_path, "data", "gtt", "gtt9_result.json"),
],
),
# HGC
(
HGC,
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,16 @@ def default(self, o):
Path(dir_path, "data", "gtt", "gtt7.eml"),
Path(dir_path, "data", "gtt", "gtt7_html_parser_result.json"),
),
(
ICal,
Path(dir_path, "data", "gtt", "gtt8"),
Path(dir_path, "data", "gtt", "gtt8_result.json"),
),
(
ICal,
Path(dir_path, "data", "gtt", "gtt9"),
Path(dir_path, "data", "gtt", "gtt9_result.json"),
),
# HGC
(
HtmlParserHGC1,
Expand Down

0 comments on commit 956c049

Please sign in to comment.