Skip to content

Commit

Permalink
They say sometimes I don't give an f. Fix that.
Browse files Browse the repository at this point in the history
Add missing f to format string.

Signed-off-by: Rick Elrod <[email protected]>
  • Loading branch information
relrod committed Oct 11, 2024
1 parent b96e64f commit df3d107
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def sync_to_resource_server(instance, action, ansible_id=None):

sync_disabled = os.environ.get('ANSIBLE_REVERSE_RESOURCE_SYNC', 'true').lower() == 'false'
if sync_disabled:
logger.info("Skipping sync of resource {instance} because $ANSIBLE_REVERSE_RESOURCE_SYNC is 'false'")
logger.info(f"Skipping sync of resource {instance} because $ANSIBLE_REVERSE_RESOURCE_SYNC is 'false'")
return

# This gets set in in signals.handlers.decide_to_sync_update() sometimes.
Expand Down
14 changes: 9 additions & 5 deletions test_app/tests/resource_registry/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,24 @@ def test_sync_to_resource_server_update_with_local_service_id(self, user, organi
'ansible_reverse_resource_sync, should_sync',
[("true", True), ("True", True), ("false", False), ("False", False), (None, True)],
)
def test_sync_to_resource_server_env_var_override(self, user, enable_reverse_sync, ansible_reverse_resource_sync, should_sync):
def test_sync_to_resource_server_env_var_override(self, user, enable_reverse_sync, ansible_reverse_resource_sync, should_sync, expected_log):
"""
We can override/disable syncing with the env var ANSIBLE_REVERSE_RESOURCE_SYNC.
"""
if ansible_reverse_resource_sync is None:
cm = nullcontext()
else:
cm = nullcontext()
if ansible_reverse_resource_sync is not None:
cm = mock.patch.dict(os.environ, ANSIBLE_REVERSE_RESOURCE_SYNC=ansible_reverse_resource_sync)

logger_cm = nullcontext()
if not should_sync:
logger_cm = expected_log(f'{utils_path}.logger', 'info', "Skipping sync of resource Hello because $ANSIBLE_REVERSE_RESOURCE_SYNC is 'false'")

with enable_reverse_sync():
with cm:
with mock.patch(f'{utils_path}.get_resource_server_client') as get_resource_server_client:
with impersonate(user):
Organization.objects.create(name='Hello')
with logger_cm:
Organization.objects.create(name='Hello')

assert get_resource_server_client.called == should_sync

Expand Down

0 comments on commit df3d107

Please sign in to comment.