Skip to content

Commit

Permalink
feat: add cap status to parsed event
Browse files Browse the repository at this point in the history
this is needed to drop status=test alerts.
  • Loading branch information
antonanders authored and jdemaeyer committed May 2, 2024
1 parent dda9821 commit 24759b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dwdparse/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ def parse_event(self, f):
'cap:identifier',
self.ns,
).text.rsplit('.', 1)[0]
elif self._is_tag(element, 'cap:status'):
event['status'] = element.text.lower()
self.sanitize_event(event)
return event

Expand Down
Binary file added tests/data/Z_CAP_with_test.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,22 @@ def test_cap_parser(data_dir):
'urgency': 'immediate',
'severity': 'moderate',
'certainty': 'likely',
'status': 'actual',
'effective': datetime.datetime(2023, 6, 23, 9, 14, tzinfo=utc),
'onset': datetime.datetime(2023, 6, 23, 9, 14, tzinfo=utc),
'expires': datetime.datetime(2023, 6, 23, 13, 0, tzinfo=utc),
}


def test_cap_parser_test_status(data_dir):
p = CAPParser()
fn = 'Z_CAP_with_test.zip'
records = list(p.parse(data_dir / fn))

assert len(records) == 1
assert records[0]['status'] == 'test'


def test_get_parser():
synop_with_timestamp = (
'Z__C_EDZW_20200617114802_bda01,synop_bufr_GER_999999_999999__MW_617'
Expand Down

0 comments on commit 24759b1

Please sign in to comment.