From 01943e8b04fd2bb4a43be2dc547d926a8f4bef61 Mon Sep 17 00:00:00 2001 From: raghuvar-vijay Date: Tue, 21 Jan 2025 13:04:57 +0100 Subject: [PATCH] fix: add special char for revert_encoding unit tests & update the migrations doc --- auditor/scripts/revert_encoding/test_script.py | 16 ++++++++-------- media/website/content/migration.md | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/auditor/scripts/revert_encoding/test_script.py b/auditor/scripts/revert_encoding/test_script.py index 64bd30ef4..b99b48929 100644 --- a/auditor/scripts/revert_encoding/test_script.py +++ b/auditor/scripts/revert_encoding/test_script.py @@ -3,17 +3,17 @@ from unittest.mock import MagicMock, patch from urllib.parse import quote -from htcondor_revert_encodings import decode_record, main +from revert_encodings import decode_record, main class TestDecodeRecord(unittest.TestCase): def test_decode_record_success(self): # Test for successful decoding - record_id = quote("test_record_id") - meta = {"key1": [quote("value1"), quote("value2")], "key2": [quote("value3")]} + record_id = quote("test_record_id/") + meta = {"key1": [quote("value1*"), quote("value2%")], "key2": [quote("value3!")]} - expected_record_id = "test_record_id" - expected_meta = {"key1": ["value1", "value2"], "key2": ["value3"]} + expected_record_id = "test_record_id/" + expected_meta = {"key1": ["value1*", "value2%"], "key2": ["value3!"]} decoded_record_id, decoded_meta = decode_record(record_id, meta) @@ -43,8 +43,8 @@ def test_main(mock_connect): # Mock database rows rows = [ - (1, quote("record1"), {"key1": [quote("value1")]}), - (2, quote("record2"), {"key2": [quote("value2")]}), + (1, quote("record1/"), {"key1": [quote("value1/")]}), + (2, quote("record2/"), {"key2": [quote("value2/")]}), ] mock_cursor.fetchall.side_effect = [rows, []] # Return rows and then stop @@ -53,7 +53,7 @@ def mock_decode_record(record_id, meta): return record_id.replace("%20", " "), json.dumps(meta) with patch( - "htcondor_revert_encodings.decode_record", side_effect=mock_decode_record + "revert_encodings.decode_record", side_effect=mock_decode_record ): main() diff --git a/media/website/content/migration.md b/media/website/content/migration.md index c276b8532..883aa6595 100644 --- a/media/website/content/migration.md +++ b/media/website/content/migration.md @@ -9,14 +9,14 @@ weight = 3 Please backup your db before proceeding with any changes that are listed below. ## Remove forbidden characters: -The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier). +The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier), follow these steps to revert the encodings in your database records: ### HTCondor collector v0.6.3 and earlier or Slurm collector v0.6.3 and earlier -- If you are running HTCondor collector (v0.6.3 and earlier) or Slurm collector v0.6.3 and earlier, you have to run the python script which reverts the encodings for the records in the db. -- The script is in the following directory `auditor/scripts/revert_encoding`. -- You can install the required dependencies with `pip install -r requirements.txt` +- Clone the github repository [git_repo](https://github.com/ALU-Schumacher/AUDITOR). +- The script for reverting encodings is located at: `auditor/scripts/revert_encoding`. +- Install the required dependencies with `pip install -r requirements.txt` +- Replace the placeholder values in the .env file with the values corresponding to your database config. - Run `python revert_encodings.py` -- Please replace your database config to the .env file which is present in this directory `auditor/scripts/revert_encoding` # From 0.6.2 to 0.6.3