Skip to content

Commit

Permalink
Fix integration test generator script and makefile command (#1441)
Browse files Browse the repository at this point in the history
* Fix integration test generator script and makefile command

* Remove test duplication and no schema name error
  • Loading branch information
petechd authored Sep 17, 2024
1 parent 5adfe30 commit 81bdf26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,5 @@ profile:
poetry run python profile_application.py

generate-integration-test:
poetry run playwright install chromium
poetry run python -m scripts.generate_integration_test
poetry run black ./scripts/test_*
12 changes: 9 additions & 3 deletions scripts/generate_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,22 @@ def process_launcher_request(request: Request) -> None:
with open(output["file_name"], "a", encoding="utf-8") as file:
path = f'"{urlparse(request.url).path}"'
file.write(generate_method_request(method="get", data=path))
else:
elif "schema_name" in parse_qs(request.url):
# start of journey, so create a skeleton file using the schema name
survey_journey["schema_name"] = parse_qs(request.url)["schema_name"][0]
output["file_name"] = f"./scripts/{survey_journey['schema_name']}.py"

with open(output["file_name"], "w", encoding="utf-8") as file:
# Type ignore: schema_name is taken as string from query string
class_name = survey_journey["schema_name"].title().replace("_", "") # type: ignore
function_name = survey_journey["schema_name"]
if not class_name.lower().startswith("test"):
class_name = f"Test{class_name}"
function_name = f"test_{survey_journey['schema_name']}"
file.write(
TEST_TEMPLATE.format(
class_name=class_name,
function_name=survey_journey["schema_name"],
function_name=function_name,
schema_name=survey_journey["schema_name"],
)
)
Expand All @@ -124,7 +128,9 @@ def request_handler(request: Request) -> None:

def run(pw: Playwright) -> None:
chromium = pw.chromium
browser = chromium.launch(headless=False, args=["--start-maximized"])
browser = chromium.launch(
headless=False, args=["--start-maximized"], channel="chrome"
)
page = browser.new_page(no_viewport=True)
page.goto(LAUNCHER_ROOT_URL)

Expand Down

0 comments on commit 81bdf26

Please sign in to comment.