Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added first unit test for pyprojen #1

Merged
merged 11 commits into from
Sep 30, 2024
Merged

Added first unit test for pyprojen #1

merged 11 commits into from
Sep 30, 2024

Conversation

avr2002
Copy link
Contributor

@avr2002 avr2002 commented Sep 28, 2024

Changes:

  • Updated author name and email address in pyproject.toml file
  • replaced logging.warn[deprecated] with logging.warning in src/pyprojen/cleanup.py
  • removed example fixtures
  • fix: added local import JsonFile from pyprojen.json_file in synth_snapshot function. Adding global import caused a circular import problem, which needs to be fixed; local import is used as a workaround.
  • added test_project fixture to setup a temporary project setup for testing; and added an empty text file generation test
  • upgraded python version to 3.10 in CI for tests to pass
    • Tests were failing because of the match case we used in the resolve file pyprojen/src/pyprojen/_resolve.py
  • completed tests for text file generation: Added 3 tests similar to projen repo

@avr2002 avr2002 requested a review from phitoduck September 28, 2024 16:43
@avr2002 avr2002 self-assigned this Sep 28, 2024
def test_project() -> Generator[Project, Any, None]:
"""Create a temporary project for testing."""
# Setup: Create a TestProject instance with a temporary directory
outdir = tempfile.mkdtemp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genius. So cool that this works.

TextFile(scope=test_project, file_path=TEST_FILE_PATH, lines=["line 1", "line 2", "line 3"])

# THEN: Take a snapshot of the project and check the file content
output: dict = synth_snapshot(test_project)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The synth_snapshot function in action!

@phitoduck phitoduck merged commit 7a7191b into main Sep 30, 2024
6 checks passed
@phitoduck
Copy link
Contributor

So great! The fact that we have an established testing framework now, and that it passes in CI is a huge step forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants