Skip to content

Commit

Permalink
More specific filename to module name
Browse files Browse the repository at this point in the history
* improved docs to reference plugin `family` name changes
* spelling for log of successful action
* more specific removal of file extension in filename

Signed-off-by: Jeffrey Martin <[email protected]>
  • Loading branch information
jmartin-tech committed Dec 2, 2024
1 parent a54ae57 commit 0a06d39
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion garak/resources/fixer/20240628_gcg_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RenameGCG(Migration):
def apply(config_dict: dict) -> dict:
"""Rename probe gcg -> suffix"""
"""Rename probe family gcg -> suffix"""

path = ["plugins", "probes"]
old = "gcg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RenameKnownbadsignatures(Migration):
def apply(config_dict: dict) -> dict:
"""Rename probe knownbadsignatures -> av_spam_scanning"""
"""Rename probe family knownbadsignatures -> av_spam_scanning"""

path = ["plugins", "probes"]
old = "knownbadsignatures"
Expand Down
2 changes: 1 addition & 1 deletion garak/resources/fixer/20241011_replay_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RenameReplay(Migration):
def apply(config_dict: dict) -> dict:
"""Rename probe replay -> divergence"""
"""Rename probe family replay -> divergence"""

path = ["plugins", "probes"]
old = "replay"
Expand Down
4 changes: 2 additions & 2 deletions garak/resources/fixer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def apply(config_dict: dict) -> dict:
continue
if module_filename.startswith("__"):
continue
module_name = module_filename.replace(".py", "")
module_name = module_filename[:-3] # strip ".py" known from check above
mod = importlib.import_module(f"{__package__}.{module_name}")
migrations = [ # Extract only classes that are a `Migration`
klass
Expand All @@ -50,6 +50,6 @@ def migrate(original_config: dict) -> dict:
logging.info(msg)

if original_config != updated_config:
logging.info("Migration preformed")
logging.info("Migration performed")

return updated_config
2 changes: 1 addition & 1 deletion tests/resources/test_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_fixer_migrate(
), "Logging should not be called when no migrations are applied"
else:
# expect `migration_name` in a log call via mock of logging.info()
assert "Migration preformed" in mock_log_info.call_args.args[0]
assert "Migration performed" in mock_log_info.call_args.args[0]
found_class = False
for calls in mock_log_info.call_args_list:
found_class = migration_name in calls.args[0]
Expand Down

0 comments on commit 0a06d39

Please sign in to comment.