Skip to content

Commit

Permalink
Merge pull request #88 from networktocode/release-v2.0.2
Browse files Browse the repository at this point in the history
Release v2.0.2
  • Loading branch information
chadell authored Sep 28, 2021
2 parents 8784032 + d8f9ac8 commit 79fb880
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.0.2 - 2021-09-28

### Fixed

- #86 - Fix `CombinedProcessor` carries over data from previous parsing

## v2.0.1 - 2021-09-16

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions circuit_maintenance_parser/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class CombinedProcessor(GenericProcessor):
# The CombinedProcessor will consolidate all the parsed data into this variable
combined_maintenance_data: Dict = {}

def process(self, data: NotificationData, extended_data: Dict) -> Iterable[Maintenance]:
"""Extend base class process method to ensure that self.combined_maintenance_data is initialized correctly."""
self.combined_maintenance_data = {}
return super().process(data, extended_data)

def process_hook(self, maintenances_extracted_data, maintenances_data):
"""All the parsers contribute with a subset of data that is extended.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "circuit-maintenance-parser"
version = "2.0.1"
version = "2.0.2"
description = "Python library to parse Circuit Maintenance notifications and return a structured data back"
authors = ["Network to Code <[email protected]>"]
license = "Apache-2.0"
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class FakeParser1(FakeParser):
# Fake data used for SimpleProcessor
fake_data = NotificationData.init_from_raw("fake_type", b"fake data")
# Fake data used for CombinedProcessor
fake_data_type_0 = NotificationData.init_from_raw("fake_type_0", b"fake data")
fake_data_for_combined = NotificationData.init_from_raw("fake_type_0", b"fake data")
if fake_data_for_combined:
fake_data_for_combined.data_parts.append(DataPart("fake_type_1", b"fake data"))
Expand Down Expand Up @@ -107,3 +108,18 @@ def test_combinedprocessor_missing_data():
processor.process(fake_data_for_combined, EXTENDED_DATA)

assert "Not enough information available to create a Maintenance notification" in str(e_info)


def test_combinedprocessor_bleed():
"""Test CombinedProcessor to make sure that information from one processing doesn't bleed over to another."""
processor = CombinedProcessor(data_parsers=[FakeParser0, FakeParser1])

with patch("circuit_maintenance_parser.processor.Maintenance") as mock_maintenance:
processor.process(fake_data_for_combined, EXTENDED_DATA)
assert mock_maintenance.call_count == 1
mock_maintenance.assert_called_with(**{**PARSED_DATA[0], **PARSED_DATA[1], **EXTENDED_DATA})

with patch("circuit_maintenance_parser.processor.Maintenance") as mock_maintenance:
processor.process(fake_data_type_0, EXTENDED_DATA)
assert mock_maintenance.call_count == 1
mock_maintenance.assert_called_with(**{**PARSED_DATA[0], **EXTENDED_DATA})

0 comments on commit 79fb880

Please sign in to comment.