Skip to content

Commit

Permalink
Fix broken test.
Browse files Browse the repository at this point in the history
Something is still wrong with the secret cases.
  • Loading branch information
tonyandrewmeyer committed Oct 3, 2023
1 parent 9e682da commit ff4e519
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ def test_setup_event_links(self):
fail = unittest.TestCase.fail
subTest = unittest.TestCase.subTest # noqa

@abc.abstractmethod
def setUp(self):
self._setup_charm_dir()

Expand Down Expand Up @@ -536,8 +535,7 @@ def test_multiple_events_handled(self):
remote_unit=None),
{'relation_name': 'mon',
'relation_id': 2,
'app_name': 'remote',
'unit_name': None},
'app_name': 'remote'},
), (
EventSpec(ops.RelationDepartedEvent, 'mon_relation_departed',
relation_id=2,
Expand All @@ -548,7 +546,7 @@ def test_multiple_events_handled(self):
'relation_id': 2,
'app_name': 'remote',
'unit_name': 'remote/0',
'departing_unit_name': 'remote/42'},
'departing_unit': 'remote/42'},
), (
EventSpec(ops.RelationBrokenEvent, 'ha_relation_broken',
relation_id=3),
Expand Down Expand Up @@ -580,7 +578,7 @@ def test_multiple_events_handled(self):
'relation_id': 2,
'app_name': 'remote',
'unit_name': 'remote/0',
'departing_unit_name': 'remote/42'},
'departing_unit': 'remote/42'},
), (
EventSpec(ops.ActionEvent, 'start_action',
env_var='JUJU_ACTION_NAME'),
Expand All @@ -598,16 +596,14 @@ def test_multiple_events_handled(self):
secret_id='secret:12345',
secret_label='foo'),
{'id': 'secret:12345',
'label': 'foo',
'revision': 42}
'label': 'foo'}
), (
EventSpec(ops.SecretRotateEvent, 'secret_rotate',
secret_id='secret:12345',
secret_label='foo',
secret_revision='42'),
{'id': 'secret:12345',
'label': 'foo',
'revision': 42}
'label': 'foo'}
), (
EventSpec(ops.SecretRemoveEvent, 'secret_remove',
secret_id='secret:12345',
Expand All @@ -634,6 +630,7 @@ def test_multiple_events_handled(self):
# Simulate hook executions for every event.
for event_spec, expected_event_data in events_under_test:
state = self._simulate_event(event_spec)
assert isinstance(state, ops.BoundStoredState)

state_key = f"on_{event_spec.event_name}"
handled_events = getattr(state, state_key, [])
Expand All @@ -646,9 +643,8 @@ def test_multiple_events_handled(self):

self.assertEqual(list(state.observed_event_types), [event_spec.event_type.__name__])

if event_spec.event_name in expected_event_data:
self.assertEqual(state[f"{event_spec.event_name}_data"],
expected_event_data[event_spec.event_name])
if expected_event_data:
self.assertEqual(getattr(state, f"{event_spec.event_name}_data"), expected_event_data)

def test_event_not_implemented(self):
"""Make sure events without implementation do not cause non-zero exit."""
Expand Down

0 comments on commit ff4e519

Please sign in to comment.