Skip to content

Conversation

@Ekam-Bitt
Copy link
Contributor

🚀 Pull Request Description

Description

This pull request introduces a robust Dockerized testing environment for the Python backend, particularly for the /generated_contracts endpoint.

Specifically, it addresses the following:

  • Dockerized Python Backend Tests: A dedicated Docker image and service (py-be-test) are set up to run all Python backend integration tests within an isolated container environment. This ensures consistent and reliable test execution.
  • Comprehensive Testing for /generated_contracts Endpoint:
    • Implementation of Missing Tests: This PR addresses the previous lack of tests for the /generated_contracts endpoint.
    • Test Valid Authenticated Request with Existing Contracts: Implemented and verified.
    • Test User with No Contracts: Implemented and verified.
    • Test Unauthorized Request: A new test case (test_get_generated_contracts_unauthorized) has been implemented to verify that the endpoint correctly returns a 401 Unauthorized status when accessed without proper authentication. A placeholder authentication mechanism (checking for an X-Token header) was added to enable this test.
    • Validate Pagination: Implemented and verified.
    • Expected Behavior: Tests confirm that GET /generated_contracts returns only contracts for the authenticated user.
  • Dynamic Database Configuration: Database connection URLs (DATABASE_URL and TEST_DATABASE_URL) are now dynamically fetched from environment variables, removing hardcoded values and allowing seamless switching between local Docker Compose and GitHub Actions environments.

This work significantly improves the development workflow by providing a reliable testing setup and enhancing security.

🔗 Linked Issues

Fixes #478

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore (refactoring, dependency updates, etc.)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Unit Tests
  • Integration Tests
  • End-to-End Tests (run docker-compose up --build py-be-test from root)
  • Tested locally with full stack setup

📸 Screenshots

[Include relevant screenshots or screen recordings demonstrating the changes]

✅ PR Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have tested these changes locally
  • Relevant documentation is updated
  • My code follows the repository's coding guidelines
  • I have added/updated tests that prove my fix/feature
  • No breaking changes introduced
  • Code is well-commented and readable

Ekam Bitt added 8 commits August 30, 2025 04:09
  This commit introduces Dockerized integration tests for the Python backend.
  This commit introduces a test case for unauthorized access to the /generated_contracts endpoint and implements a basic authentication
  placeholder to enable this test.
@vercel
Copy link

vercel bot commented Aug 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stark-finder-mq45 Ready Ready Preview Comment Aug 30, 2025 1:42pm

Copy link
Contributor

@tosoham tosoham left a comment

Choose a reason for hiding this comment

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

Fix merge conflicts

Copy link
Contributor

@tosoham tosoham left a comment

Choose a reason for hiding this comment

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

LGTM

@tosoham
Copy link
Contributor

tosoham commented Aug 30, 2025

@Ekam-Bitt please fix linting and tests in backend of Anon

@Ekam-Bitt
Copy link
Contributor Author

@Ekam-Bitt please fix linting and tests in backend of Anon

it's a clippy error, passing all checks in local environment but failing in github actions

@tosoham tosoham merged commit 0a21155 into Shonen-Labs:main Aug 30, 2025
7 of 10 checks passed
@Ekam-Bitt Ekam-Bitt deleted the fix-478-test-get-generated-contracts-endpoint branch August 30, 2025 17:43
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.

Test GET /generated_contracts Endpoint

2 participants