From 8acca0dc8f17a5df21a2c4f7665a23569fac9923 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Wed, 1 Feb 2023 11:14:29 -0500 Subject: [PATCH] Support testing dests with backrefs --- group_vars/all.yaml | 6 ++++-- tests/test_function.py | 14 ++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/group_vars/all.yaml b/group_vars/all.yaml index 5f036ef..01c8b6e 100644 --- a/group_vars/all.yaml +++ b/group_vars/all.yaml @@ -90,5 +90,7 @@ gxy_io_rewrites: - src: "/t/(.*)" dest: "https://training.galaxyproject.org/training-material/short/\\1" tests: - - /t/ansible-galaxy - - /t/galaxy-intro-101 + - src: /t/ansible-galaxy + dest: https://training.galaxyproject.org/training-material/short/ansible-galaxy + - src: /t/galaxy-intro-101 + dest: https://training.galaxyproject.org/training-material/short/galaxy-intro-101 diff --git a/tests/test_function.py b/tests/test_function.py index 8061577..295b2e1 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -86,15 +86,13 @@ def event_for_uri(uri): def test_rewrite(rewrite, test_collector): - for test_uri in rewrite.get("tests", [rewrite["src"]]): - event = event_for_uri(test_uri) + for test_def in rewrite.get("tests", [rewrite["src"]]): + if not isinstance(test_def, dict): + test_def = {"src": test_def, "dest": rewrite["dest"]} + event = event_for_uri(test_def["src"]) location = lambda_handler(event, None)["headers"]["location"][0]["value"] - test_name = f"{test_uri}: {location} -> {rewrite['dest']}" - if '\\1' in rewrite['dest']: - # Skip tests with replacements? - test_collector.add_results(True, test_name) - else: - test_collector.add_results(location == rewrite["dest"], test_name) + test_name = f"{test_def['src']}: {location} -> {test_def['dest']}" + test_collector.add_results(location == test_def["dest"], test_name) def main():