Skip to content

Commit

Permalink
Fix e2e test while combining data from multiple maintenances
Browse files Browse the repository at this point in the history
Fix e2e test while combining data from multiple maintenances
  • Loading branch information
scetron authored Mar 21, 2023
2 parents 9586d47 + fda6541 commit 1127d45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
6 changes: 2 additions & 4 deletions tests/unit/data/date/email_date_1_result.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[
{
{
"stamp": 1612172014
}
]
}
30 changes: 24 additions & 6 deletions tests/unit/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from circuit_maintenance_parser.errors import ProviderError
from circuit_maintenance_parser.constants import EMAIL_HEADER_DATE, EMAIL_HEADER_SUBJECT

# pylint: disable=duplicate-code
# pylint: disable=duplicate-code,too-many-lines
from circuit_maintenance_parser.provider import (
Equinix,
GenericProvider,
Expand Down Expand Up @@ -463,12 +463,11 @@
Lumen,
[
("html", Path(dir_path, "data", "lumen", "lumen8.html")),
# (EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
(EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
(EMAIL_HEADER_SUBJECT, Path(dir_path, "data", "lumen", "subject_work_planned")),
],
[
Path(dir_path, "data", "lumen", "lumen8_result.json"),
# Path(dir_path, "data", "date", "email_date_1_result.json"),
],
),
# Megaport
Expand Down Expand Up @@ -726,6 +725,17 @@
Path(dir_path, "data", "date", "email_date_1_result.json"),
],
),
(
Verizon,
[
("html", Path(dir_path, "data", "verizon", "verizon4.html")),
(EMAIL_HEADER_DATE, Path(dir_path, "data", "date", "email_date_1")),
],
[
Path(dir_path, "data", "verizon", "verizon4_result.json"),
Path(dir_path, "data", "date", "email_date_1_result.json"),
],
),
(
Verizon,
[
Expand Down Expand Up @@ -823,7 +833,7 @@
)
def test_provider_get_maintenances(
provider_class, test_data_files, result_parse_files
): # pylint: disable=too-many-locals
): # pylint: disable=too-many-locals,too-many-branches
"""End to End tests for various Providers."""
extended_data = provider_class.get_extended_data()
default_maintenance_data = {"uid": "0", "sequence": 1, "summary": ""}
Expand All @@ -849,10 +859,18 @@ def test_provider_get_maintenances(
for result_parse_file in result_parse_files:
with open(result_parse_file, encoding="utf-8") as res_file:
partial_result_data = json.load(res_file)
if not expected_result:

# TODO: Tests assume that maintenances (multiple) will be discovered on the first parser
if not expected_result and isinstance(partial_result_data, list):
expected_result = partial_result_data

if expected_result and isinstance(partial_result_data, dict):
for _ in range(len(expected_result)):
expected_result[0].update(partial_result_data)
else:
expected_result[0].update(partial_result_data[0])
assert len(expected_result) == len(partial_result_data)
for i, _ in enumerate(partial_result_data):
expected_result[i].update(partial_result_data[i])

for result in expected_result:
temp_res = result.copy()
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,10 @@ def test_parsers(parser_class, raw_file, results_file):
with open(results_file, encoding="utf-8") as res_file:
expected_result = json.load(res_file)

assert parsed_notifications == expected_result
if parser_class == EmailDateParser:
assert parsed_notifications == [expected_result]
else:
assert parsed_notifications == expected_result


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

0 comments on commit 1127d45

Please sign in to comment.