Skip to content

Commit

Permalink
chore: Fix local SDK use in cookiecutter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 31, 2025
1 parent 3c80245 commit 0bf2d6a
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import shutil
import sys
import tempfile
from pathlib import Path

import nox
Expand Down Expand Up @@ -187,38 +186,38 @@ def docs_serve(session: nox.Session) -> None:

@nox.parametrize("replay_file_path", COOKIECUTTER_REPLAY_FILES)
@nox.session(python=main_python_version)
def test_cookiecutter(session: nox.Session, replay_file_path: str) -> None:
def test_cookiecutter(session: nox.Session, replay_file_path: Path) -> None:
"""Uses the tap template to build an empty cookiecutter.
Runs the lint task on the created test project.
"""
cc_build_path = Path(tempfile.gettempdir())
cc_build_path = Path(session.create_tmp())
folder_base_path = Path("./cookiecutter")
replay_file = Path(replay_file_path).resolve()
replay_file = replay_file_path.resolve()

if replay_file.name.startswith("tap"):
folder = "tap-template"
elif replay_file.name.startswith("target"):
folder = "target-template"
else:
folder = "mapper-template"
template = folder_base_path.joinpath(folder).resolve()
template = folder_base_path.joinpath(folder)

if not template.exists():
return

if not replay_file.is_file():
return

sdk_dir = template.parent.parent
sdk_dir = template.parent.parent.resolve()
cc_output_dir = replay_file.name.replace(".json", "")
cc_test_output = cc_build_path.joinpath(cc_output_dir)

if cc_test_output.exists():
session.run("rm", "-fr", str(cc_test_output), external=True)

session.install(".")
session.install("cookiecutter", "pythonsed")
session.install("cookiecutter")

session.run(
"cookiecutter",
Expand All @@ -233,14 +232,9 @@ def test_cookiecutter(session: nox.Session, replay_file_path: str) -> None:
with Path("ruff.toml").open("w", encoding="utf-8") as ruff_toml:
ruff_toml.write(RUFF_OVERRIDES)

session.run(
"pythonsed",
"-i.bak",
's|singer-sdk =.*|singer-sdk = \\{ path = "'
+ str(sdk_dir)
+ '", develop = true \\}|',
"pyproject.toml",
)
# Use the local singer-sdk
session.run("uv", "add", f"singer-sdk @ {sdk_dir}", external=True)
session.run("cat", "pyproject.toml")

# Check that the project can be installed for development
session.run("uv", "lock", external=True)
Expand Down

0 comments on commit 0bf2d6a

Please sign in to comment.