Skip to content

Commit

Permalink
Resolves #873.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Jan 10, 2025
1 parent f8dce4c commit 8fb1290
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__
*.log
Islandora_Workbench.egg-info/
dist/
tests_local/
62 changes: 62 additions & 0 deletions scripts/make_local_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Utility script to replace host, username, and password values in
Islandora Workbench test config files.
Usage (run from within the workbench directory):
python scripts/make_local_tests.py
or, with any of the optional arguments:
python scripts/make_local_tests.py --host http://localhost:8080 --username mark --password islandora
"""

import os
import sys
import shutil
import glob
import argparse

current_dir = os.getcwd()
path_to_workbench = os.path.join(current_dir, "workbench")
if os.path.isfile(path_to_workbench) is False:
sys.exit(f"This script must be run from the workbench directory.")

parser = argparse.ArgumentParser()

parser.add_argument(
"--host",
help='The "host" setting value to use in your local test config files.',
default="https://islandora.traefik.me",
)
parser.add_argument(
"--username",
help='The "username" setting value to use in your local test config files.',
default="admin",
)
parser.add_argument(
"--password",
help='The "password" setting value to use in your local test config files.',
default="password",
)
args = parser.parse_args()

tests_dir = "tests"
local_tests_dir = "tests_local"

if os.path.exists(local_tests_dir):
shutil.rmtree(local_tests_dir)

shutil.copytree(tests_dir, local_tests_dir, dirs_exist_ok=True)

for filepath in glob.iglob(f"{local_tests_dir}/**/*.yml", recursive=True):
f = open(filepath)
config = f.read()
if args.host != "https://islandora.traefik.me":
config = config.replace("https://islandora.dev", args.host)
if args.username != "admin":
config = config.replace("admin", args.username)
if args.password != "password":
config = config.replace("password", args.password)
config = config.replace("tests/assets/", "tests_local/assets/")
f = open(filepath, "w")
f.write(config)

0 comments on commit 8fb1290

Please sign in to comment.