Skip to content

Commit 1127d45

Browse files
authored
Fix e2e test while combining data from multiple maintenances
Fix e2e test while combining data from multiple maintenances
2 parents 9586d47 + fda6541 commit 1127d45

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[
2-
{
1+
{
32
"stamp": 1612172014
4-
}
5-
]
3+
}

tests/unit/test_e2e.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from circuit_maintenance_parser.errors import ProviderError
1010
from circuit_maintenance_parser.constants import EMAIL_HEADER_DATE, EMAIL_HEADER_SUBJECT
1111

12-
# pylint: disable=duplicate-code
12+
# pylint: disable=duplicate-code,too-many-lines
1313
from circuit_maintenance_parser.provider import (
1414
Equinix,
1515
GenericProvider,
@@ -463,12 +463,11 @@
463463
Lumen,
464464
[
465465
("html", Path(dir_path, "data", "lumen", "lumen8.html")),
466-
# (EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
466+
(EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
467467
(EMAIL_HEADER_SUBJECT, Path(dir_path, "data", "lumen", "subject_work_planned")),
468468
],
469469
[
470470
Path(dir_path, "data", "lumen", "lumen8_result.json"),
471-
# Path(dir_path, "data", "date", "email_date_1_result.json"),
472471
],
473472
),
474473
# Megaport
@@ -726,6 +725,17 @@
726725
Path(dir_path, "data", "date", "email_date_1_result.json"),
727726
],
728727
),
728+
(
729+
Verizon,
730+
[
731+
("html", Path(dir_path, "data", "verizon", "verizon4.html")),
732+
(EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
733+
],
734+
[
735+
Path(dir_path, "data", "verizon", "verizon4_result.json"),
736+
Path(dir_path, "data", "date", "email_date_1_result.json"),
737+
],
738+
),
729739
(
730740
Verizon,
731741
[
@@ -823,7 +833,7 @@
823833
)
824834
def test_provider_get_maintenances(
825835
provider_class, test_data_files, result_parse_files
826-
): # pylint: disable=too-many-locals
836+
): # pylint: disable=too-many-locals,too-many-branches
827837
"""End to End tests for various Providers."""
828838
extended_data = provider_class.get_extended_data()
829839
default_maintenance_data = {"uid": "0", "sequence": 1, "summary": ""}
@@ -849,10 +859,18 @@ def test_provider_get_maintenances(
849859
for result_parse_file in result_parse_files:
850860
with open(result_parse_file, encoding="utf-8") as res_file:
851861
partial_result_data = json.load(res_file)
852-
if not expected_result:
862+
863+
# TODO: Tests assume that maintenances (multiple) will be discovered on the first parser
864+
if not expected_result and isinstance(partial_result_data, list):
853865
expected_result = partial_result_data
866+
867+
if expected_result and isinstance(partial_result_data, dict):
868+
for _ in range(len(expected_result)):
869+
expected_result[0].update(partial_result_data)
854870
else:
855-
expected_result[0].update(partial_result_data[0])
871+
assert len(expected_result) == len(partial_result_data)
872+
for i, _ in enumerate(partial_result_data):
873+
expected_result[i].update(partial_result_data[i])
856874

857875
for result in expected_result:
858876
temp_res = result.copy()

tests/unit/test_parsers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,10 @@ def test_parsers(parser_class, raw_file, results_file):
549549
with open(results_file, encoding="utf-8") as res_file:
550550
expected_result = json.load(res_file)
551551

552-
assert parsed_notifications == expected_result
552+
if parser_class == EmailDateParser:
553+
assert parsed_notifications == [expected_result]
554+
else:
555+
assert parsed_notifications == expected_result
553556

554557

555558
@pytest.mark.parametrize("parser_class", [ICal, EmailDateParser, HtmlParserZayo1, SubjectParserZayo1])

0 commit comments

Comments
 (0)