Skip to content

Commit

Permalink
Address issues from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Dec 3, 2024
1 parent d8a89d5 commit 53211a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ops/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def _get_event_to_emit(self, event_name: str) -> Optional[ops.framework.BoundEve
return getattr(self.charm.on, event_name)
except AttributeError:
logger.debug('Event %s not defined for %s.', event_name, self.charm)
# If the event is not defined, return None.
return None

def _emit_charm_event(self, event_name: str):
"""Emits a charm event based on a Juju event name.
Expand All @@ -522,10 +522,12 @@ def _emit_charm_event(self, event_name: str):

# If the event is not supported by the charm implementation, do
# not error out or try to emit it. This is to support rollbacks.
if event_to_emit is not None:
args, kwargs = _get_event_args(self.charm, event_to_emit, self._juju_context)
logger.debug('Emitting Juju event %s.', event_name)
event_to_emit.emit(*args, **kwargs)
if event_to_emit is None:
return

args, kwargs = _get_event_args(self.charm, event_to_emit, self._juju_context)
logger.debug('Emitting Juju event %s.', event_name)
event_to_emit.emit(*args, **kwargs)

def _commit(self):
"""Commit the framework and gracefully teardown."""
Expand Down
1 change: 1 addition & 0 deletions testing/src/scenario/_consistency_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def check_event_consistency(
"(e.g. a relation event, or a workload event), you might get some false-negative "
"consistency checks.",
)
return Results(errors, warnings)

if event._is_relation_event:
_check_relation_event(charm_spec, event, state, errors, warnings)
Expand Down

0 comments on commit 53211a0

Please sign in to comment.