Skip to content

Conversation

@jaswanthDuddu
Copy link
Member

@jaswanthDuddu jaswanthDuddu commented Oct 24, 2025

Description

This pull request introduces two major new features to the backend, complete with testing:

  1. Single Opportunity Endpoint: Implements a new route (GET /opportunity/<int:opportunity_id>) to fetch all details for a single opportunity. This also includes helper functions to properly serialize the opportunity data for the JSON response.
  2. User Profile Management: Adds two new protected routes, GET /profile and PUT /profile. These endpoints allow an authenticated user to fetch their own profile data and update it, including personal details (name, website, etc.) and their associated majors and departments.

These changes provide the core API functionality needed for the frontend to build the individual opportunity view page and the user profile settings page.

Fixes # (issue)

(Please link the relevant issue number here, if one exists)

Type of change

  • 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)
  • This change requires a documentation update

How Has This Been Tested?

This PR has been tested by adding new unit test files for both major features:

  1. Single Opportunity Endpoint:

    • Tests were added/updated in test_opportunity.py and test_single_opportunity_routes.py.
    • These tests verify that the endpoint successfully returns the correct opportunity data for a valid ID and correctly returns a 404 error for a non-existent ID.
  2. User Profile Management:

    • A new test file, test_profile_routes.py, was created to provide full coverage for the new endpoints.
    • Tests cover GET /profile success (for an authenticated user) and failure (for an unauthorized user).
    • Tests cover PUT /profile success (for both full and partial data updates) and failure (for an unauthorized user).

All new and existing unit tests pass locally with these changes. The User Profile Management is not fully passing, as the existing authentication code needs fixes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my 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 (if a larger change)
  • New and existing unit tests pass locally with my changes

jaswanthDuddu and others added 12 commits September 29, 2025 18:15
new route that queries the database for all opportunities and returns them as a JSON list
test to ensure your new endpoint works correctly
creating a specific backend route to fetch the details of one opportunity by its ID
test verifies that the new endpoint correctly retrieves an opportunity  or handle error
Added opportunity_to_dict helper
Fix two GET endpoints for better error checks and improved data handling
created corresponding tests in test_single_opportunity_routes.py
for a smooth experience
GET /profile route to allow users to fetch their own profile data.
Added a 'user_to_dict' helper function to consistently serialize user data.
PUT /profile route for user to update their personal details.
PUT /profile route for user to update their majors and department.
GET /profile endpoint: both successful data retrieval and unauthorized access
PUT /profile endpoint: ensuring that full updates, partial updates, and unauthorized attempts are handled correctly.
ISSUE: Login helper function to streamline authentication within the tests but the tests fail as user not in DB.
@deepsource-io
Copy link

deepsource-io bot commented Oct 24, 2025

Here's the code health analysis summary for commits bcbff90..dcc07ff. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Member

@RafaelCenzano RafaelCenzano left a comment

Choose a reason for hiding this comment

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

Make sure linting passes on changes. If you are using vscode you can use the ruff extension https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff. Or just call ruff directly as it should be installed.

@jaswanthDuddu
Copy link
Member Author

@RafaelCenzano fixed the lint error

Copy link
Member

@RafaelCenzano RafaelCenzano left a comment

Choose a reason for hiding this comment

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

LGTM

@WBroadwell WBroadwell merged commit 62dab3c into LabConnect-RCOS:Single-Opportunity-and-User-Profile-Management Oct 24, 2025
3 of 4 checks passed
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.

3 participants