Skip to content

Generate Unit Tests for github_service.py #175

@dhirenmathur

Description

@dhirenmathur

Description:

We need to create unit tests for the github_service.py file located in the app/modules/github/ directory. The goal is to ensure that all functions are thoroughly tested for expected behavior, edge cases, and error handling.

Functions to Test:

  1. get_github_repo_details: Test the retrieval of GitHub repository details, including handling of invalid repository names and API errors.

  2. get_file_content: Validate file content retrieval, including:

    • Successful access to private and public repositories.
    • Handling of directory paths instead of file paths.
    • Correct line selection based on start_line and end_line.
  3. get_repos_for_user: Validate the retrieval of repositories for a user, including error handling for missing users and tokens.

  4. get_combined_user_repos: Test the combination of user repositories and project repositories, ensuring no duplicates.

  5. get_branch_list: Validate branch retrieval, including error handling for non-existent repositories.

  6. get_public_github_instance: Ensure that a public GitHub instance is returned correctly.

  7. get_repo: Test the retrieval of a repository, including handling of both private and public access failures.

  8. get_project_structure_async: Validate the fetching of project structure, including caching behavior.

Testing Framework:

  • Use pytest for writing the unit tests.
  • Consider using pytest-mock or unittest.mock to mock external dependencies like GitHub API calls and database interactions.

Acceptance Criteria:

  • All functions have corresponding unit tests.
  • Tests cover both happy paths and edge cases.
  • Code coverage should be at least 80%.

Additional Notes:

  • Please ensure that the tests are organized and follow best practices for readability and maintainability.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions