bb-plane-fork/apiserver/plane
Mohamed Hayballa 6000639921
feat(tests): Add comprehensive test suite for the Project API (#7252)
* feat(tests): Add reusable workspace fixture

Introduces a new `workspace` fixture in `conftest.py` to provide a
consistent and reusable setup for tests that require a workspace.

* feat(tests): Add tests for project creation (POST)

This commit introduces a comprehensive test suite for the project creation API endpoint.

The suite covers a wide range of scenarios, including:
- Successful creation and verification of side-effects (default states, project members, user properties).
- Validation for invalid or missing data (400 Bad Request).
- Permission checks for different user roles (e.g., guests are forbidden).
- Authentication requirements (401 Unauthorized).
- Uniqueness constraints for project names and identifiers (409 Conflict).
- Successful creation with all optional fields populated.

It leverages the `workspace`, `session_client` and `create_user` fixtures for a consistent test setup.

* refactor(tests): Centralize project URL helper into a base class

To avoid code duplication in upcoming tests, this commit introduces a `TestProjectBase` class.

The `get_project_url` helper method is moved into this shared base class, and the existing `TestProjectAPIPost` class is updated to inherit from it. This ensures the URL generation logic is defined in a single place and preparing the suite for the upcoming GET tests.

* feat(tests): Add tests for project listing and retrieval (GET)

This commit adds a suite for the GET method. It leverages the previously created `TestProjectBase` class for URL generation.

The new test suite covers:
- Listing projects:
  - Verifies that administrators see all projects.
  - Confirms guests only see projects they are members of.
  - Tests the separate detailed project list endpoint.
- Retrieving a single project:
  - Checks for successful retrieval of a project by its ID.
  - Handles edge cases for non-existent and archived projects (404 Not Found).
- Authentication:
  - Ensures authentication is required (401 Unauthorized).

* feat(tests): Add tests for project update (PATCH) and deletion (DELETE)

Key scenarios tested for PATCH:
- Successful partial updates by project administrators.
- Forbidden access for non-admin members (403).
- Conflict errors for duplicate names or identifiers on update (409).
- Validation errors for invalid data (400).

Key scenarios tested for DELETE:
- Successful deletion by both project admins and workspace admins.
- Forbidden access for non-admin members (403).
- Authentication checks for unauthenticated users (401).

* Remove unnecessary print statement

* refactor(tests): Update workspace fixture to use ORM

Updates the `workspace` fixture to create the model instance directly via the ORM using the `Workspace` model instead of the API, as requested during code review.

* Refactor: Remove some unused imports

Removes imports that I added while working on the test suite for the Project API but were ultimately not used. Note that other unused imports still exist from the state of the codebase when this branch was created/forked.
2025-07-03 00:40:42 +05:30
..
analytics chore: formatting all python files using black formatter (#3366) 2024-01-22 13:19:43 +05:30
api [WEB 4252] chore: updated the favicon request for work item link (#7173) 2025-06-06 15:02:00 +05:30
app [WEB-4373]: optimize backend query for workspace views and Project gantt view (#7267) 2025-06-25 19:10:24 +05:30
authentication [WEB-3707] pytest based test suite for apiserver (#7010) 2025-05-26 15:26:26 +05:30
bgtasks [WEB-4063]chore: updated work item email template (#7044) 2025-06-08 23:46:12 +05:30
db Chore: replace relation choices with TextChoices in IssueRelation model (#7295) 2025-07-01 12:36:27 +05:30
license [WEB-4146] fix: AI environment variables configuration in GodMode (#7104) 2025-05-23 15:06:58 +05:30
middleware [WEB-4144] fix: api logger to handle content decode errors #7099 2025-05-23 15:31:40 +05:30
seeds/data [WEB-3945] chore: update workspace onboarding to add default project (#6964) 2025-04-29 14:01:22 +05:30
settings fix: ruff file formatting based on config file pyproject (#7082) 2025-05-19 17:34:46 +05:30
space [WEB-4115] fix: update issue count status query to handle null values #7080 2025-05-23 16:13:48 +05:30
static build: merge frontend and backend into a single repo 2022-11-30 02:47:42 +05:30
tests feat(tests): Add comprehensive test suite for the Project API (#7252) 2025-07-03 00:40:42 +05:30
utils [WEB-4418]fix: fixed the pagination for issues #7301 2025-07-01 15:03:20 +05:30
web chore: adding robots txt file for not indexing the server 2025-05-09 21:07:24 +05:30
__init__.py chore: formatting all python files using black formatter (#3366) 2024-01-22 13:19:43 +05:30
asgi.py chore: formatting changes 2024-11-21 17:42:44 +05:30
celery.py [WEB-3927] chore: add logging to support json logging (#6955) 2025-04-22 17:41:58 +05:30
urls.py chore: adding robots txt file for not indexing the server 2025-05-09 21:07:24 +05:30
wsgi.py chore: formatting all python files using black formatter (#3366) 2024-01-22 13:19:43 +05:30