Skip to content

Backend Unit Tests

oguzpancuk edited this page Dec 20, 2024 · 1 revision

Onboarding Unit Tests

RegisterViewTest

Test Case: Register a Valid User

  • Description: Tests registration of a user with valid credentials.
  • Input: Valid username, email, and password.
  • Expected Output: Status 201, user is created, and a confirmation email is sent.
  • Result: Pass

Test Case: Register with Invalid Credentials

  • Description: Tests registration with missing/invalid credentials.
  • Input: Missing username, invalid email, short password.
  • Expected Output: Status 400, no user is created.
  • Result: Pass

VerifyEmailTest

Test Case: Verify Email with Valid Token

  • Description: Tests email verification with a valid token.
  • Input: Valid JWT token.
  • Expected Output: Status 200, user email marked as verified.
  • Result: Pass

Test Case: Verify Email with Expired Token

  • Description: Tests email verification with an expired token.
  • Input: Expired JWT token.
  • Expected Output: Status 400, error "Activation Expired."
  • Result: Pass

Test Case: Verify Email with Invalid Token

  • Description: Tests email verification with an invalid token.
  • Input: Invalid JWT token string.
  • Expected Output: Status 400, error "Invalid token."
  • Result: Pass

Test Case: Verify Email Already Verified

  • Description: Tests email verification for a user already verified.
  • Input: Valid JWT token for an already verified user.
  • Expected Output: Status 400, error "Email already verified."
  • Result: Pass

MyObtainTokenPairViewTest

Test Case: Obtain Token with Valid Credentials

  • Description: Tests login and token retrieval with valid credentials.
  • Input: Valid username and password.
  • Expected Output: Status 200, access and refresh tokens returned.
  • Result: Pass

Test Case: Obtain Token with Invalid Credentials

  • Description: Tests login with incorrect credentials.
  • Input: Valid username, incorrect password.
  • Expected Output: Status 401, error message returned.
  • Result: Pass

UserViewSetTest

Test Case: List Users

  • Description: Tests retrieving a list of users.
  • Input: None.
  • Expected Output: Status 200, list of users.
  • Result: Pass

Test Case: Retrieve a User

  • Description: Tests retrieving a specific user's details.
  • Input: User ID.
  • Expected Output: Status 200, user details.
  • Result: Pass

Test Case: Create a New User

  • Description: Tests creating a new user.
  • Input: Valid user data.
  • Expected Output: Status 201, user is created.
  • Result: Pass

Test Case: Update a User

  • Description: Tests updating an existing user's details.
  • Input: User ID and updated data.
  • Expected Output: Status 200, user details updated.
  • Result: Pass

Test Case: Delete a User

  • Description: Tests deleting an existing user.
  • Input: User ID.
  • Expected Output: Status 204, user is deleted.
  • Result: Pass

Test Case: Get User by Username

  • Description: Tests retrieving user by username.
  • Input: Username.
  • Expected Output: Status 200, user details returned.
  • Result: Pass

Test Case: Get User by Nonexistent Username

  • Description: Tests retrieving user by a nonexistent username.
  • Input: Username.
  • Expected Output: Status 404, error "User not found."
  • Result: Pass

ProfileViewSetTest

Test Case: List Profiles

  • Description: Tests retrieving a list of profiles.
  • Input: None.
  • Expected Output: Status 200, list of profiles.
  • Result: Pass

Test Case: Retrieve a Profile

  • Description: Tests retrieving a specific user's profile.
  • Input: Profile ID.
  • Expected Output: Status 200, profile details.
  • Result: Pass

Test Case: Update a Profile

  • Description: Tests updating a user's profile.
  • Input: Profile ID and updated data.
  • Expected Output: Status 200, profile details updated.
  • Result: Pass

Test Case: Delete a Profile

  • Description: Tests deleting a user's profile.
  • Input: Profile ID.
  • Expected Output: Status 204, profile deleted.
  • Result: Pass

FollowUnfollowViewTest

Test Case: Follow a User

  • Description: Tests following a user.
  • Input: Username of the user to follow.
  • Expected Output: Status 200, success message returned.
  • Result: Pass

Test Case: Follow Already Followed User

  • Description: Tests following a user already followed.
  • Input: Username of the user already followed.
  • Expected Output: Status 400, error "Already following this user."
  • Result: Pass

Test Case: Follow Nonexistent User

  • Description: Tests following a nonexistent user.
  • Input: Username of a nonexistent user.
  • Expected Output: Status 404, error "User not found."
  • Result: Pass

Test Case: Unfollow a User

  • Description: Tests unfollowing a user.
  • Input: Username of the user to unfollow.
  • Expected Output: Status 200, success message returned.
  • Result: Pass

Test Case: Unfollow a User Not Followed

  • Description: Tests unfollowing a user not currently followed.
  • Input: Username of the user not followed.
  • Expected Output: Status 400, error "You are not following this user."
  • Result: Pass

Test Case: Unfollow Nonexistent User

  • Description: Tests unfollowing a nonexistent user.
  • Input: Username of a nonexistent user.
  • Expected Output: Status 404, error "User not found."
  • Result: Pass

Marketfeed Unit Tests

PortfolioViewSetTests

Test Case: List Portfolios

  • Description: Tests retrieving a list of portfolios for a logged-in user.
  • Input: None.
  • Expected Output: Status 200, list of portfolios for the user.
  • Result: Pass

PostViewSetTests

Test Case: List Posts

  • Description: Tests retrieving a list of posts.
  • Input: None.
  • Expected Output: Status 200, list of posts.
  • Result: Pass

Test Case: Retrieve Post

  • Description: Tests retrieving a specific post by ID.
  • Input: Post ID.
  • Expected Output: Status 200, post details.
  • Result: Pass

Test Case: Delete Post

  • Description: Tests deleting a specific post by ID.
  • Input: Post ID.
  • Expected Output: Status 204, post deleted.
  • Result: Pass

CurrencyViewSetTest

Test Case: List Currencies

  • Description: Tests retrieving a list of currencies.
  • Input: None.
  • Expected Output: Status 200, list of currencies.
  • Result: Pass

Test Case: Create Currency

  • Description: Tests creating a new currency with valid data.
  • Input: Valid currency data.
  • Expected Output: Status 201, currency created.
  • Result: Pass

Test Case: Create Invalid Currency

  • Description: Tests creating a currency with invalid data.
  • Input: Invalid currency data.
  • Expected Output: Status 400, validation error.
  • Result: Pass

Test Case: Retrieve Currency

  • Description: Tests retrieving a specific currency by ID.
  • Input: Currency ID.
  • Expected Output: Status 200, currency details.
  • Result: Pass

Test Case: Update Currency

  • Description: Tests updating an existing currency.
  • Input: Currency ID and updated data.
  • Expected Output: Status 200, currency details updated.
  • Result: Pass

Test Case: Delete Currency

  • Description: Tests deleting a specific currency by ID.
  • Input: Currency ID.
  • Expected Output: Status 204, currency deleted.
  • Result: Pass

StockViewSetTest

Test Case: List Stocks

  • Description: Tests retrieving a list of stocks.
  • Input: None.
  • Expected Output: Status 200, list of stocks.
  • Result: Pass

Test Case: Retrieve Stock

  • Description: Tests retrieving a specific stock by ID.
  • Input: Stock ID.
  • Expected Output: Status 200, stock details.
  • Result: Pass

Test Case: Create Stock

  • Description: Tests creating a new stock with valid data.
  • Input: Valid stock data.
  • Expected Output: Status 201, stock created.
  • Result: Pass

Test Case: Create Invalid Stock

  • Description: Tests creating a stock with invalid data.
  • Input: Invalid stock data.
  • Expected Output: Status 400, validation error.
  • Result: Pass

Test Case: Update Stock

  • Description: Tests updating an existing stock.
  • Input: Stock ID and updated data.
  • Expected Output: Status 200, stock details updated.
  • Result: Pass

Test Case: Delete Stock

  • Description: Tests deleting a specific stock by ID.
  • Input: Stock ID.
  • Expected Output: Status 204, stock deleted.
  • Result: Pass

Test Case: Stock Pattern Search

  • Description: Tests searching for stocks by a pattern.
  • Input: Pattern and limit.
  • Expected Output: Status 200, matching stocks returned.
  • Result: Pass

Annotation Unit Tests

AnnotationViewSetIntegrationTests

Test Case: Create Annotation

  • Description: Tests creating a new annotation with valid data.
  • Input: Valid annotation data including body, target, and creator.
  • Expected Output: Status 201, annotation is created with correct source.
  • Result: Pass

Test Case: Get Annotations by Source

  • Description: Tests retrieving annotations by the specified source ID.
  • Input: Source ID of an existing annotation.
  • Expected Output: Status 200, annotations for the given source returned.
  • Result: Pass

Test Case: Get Annotations by Source Not Found

  • Description: Tests retrieving annotations when no annotations exist for the specified source.
  • Input: Nonexistent source ID.
  • Expected Output: Status 404, error message "No annotations found for the specified source."
  • Result: Pass

📋 Lab Reports

📆 Meeting Notes

🧪 Lab Meetings

🗓️ General Meetings

⚙️ Backend Meetings

📝 Milestone Reports

📑 Project Artifacts

📖 Manuals

📑 Other Artifacts

📋 Software Requirements Specification

📊 Software Design Documents

✏️ User Scenarios & Mockups

🗂 Project Plan

🧪 Unit Tests

📜 Docs

👥 Team

SemanticFlix Archieve

📝 Milestone Reports

📆 Meeting Notes

🧾 Requirements

Project Plan

📊 Diagrams

👥 Team

📝 Researches

Repository Documentations

📁 Templates

Clone this wiki locally