Skip to content

Commit

Permalink
Add a test checking that a warning is logged in case of nodes having …
Browse files Browse the repository at this point in the history
…weight != 1
  • Loading branch information
ptormene committed Jul 18, 2023
1 parent 9b841e3 commit 58106fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions openquake/calculators/tests/infrastructure_risk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,19 @@ def test_multiple_graphtypes(self):
' all equal values.')
self.assertIn(got_msg_head, exc_msg)
self.assertIn(got_msg_tail, exc_msg)

def test_weighted_nodes(self):
with self.assertLogs(level='WARNING') as log:
expected_log_head = 'Node weights different from 1 present in'
expected_log_tail = (
'exposure_demo_weighted_nodes.csv will be ignored.'
' Handling node weights is not implemented yet.')
self.run_calc(eff_loss_random.__file__, 'job_weighted_nodes.ini')
warning_was_found = False
for record in log.records:
if record.msg.startswith(expected_log_head):
self.assertIn(expected_log_tail, record.msg)
warning_was_found = True
self.assertTrue(
warning_was_found,
'If there are node weights != 1, a warning should be raised')

0 comments on commit 58106fd

Please sign in to comment.