Skip to content

Add unit tests for GitLab tools (Commits, File, MRs, Pipelines) #993

@yashksaini-coder

Description

@yashksaini-coder

Summary

Four GitLab tools have no unit tests under tests/tools/: GitLabCommitsTool, GitLabFileTool, GitLabMRsTool, and GitLabPipelinesTool. An inline test exists at app/integrations/gitlab_test.py (tracked separately by #901) but it only covers the config/integration layer.

Context

The four tools live under app/tools/GitLab*Tool/. They make read-only REST calls to the GitLab API using a token from sources["gitlab"]. Other similar provider tools (GitHub, Bitbucket) provide a good pattern to follow.

What to implement

Create four files:

  • tests/tools/test_gitlab_commits_tool.py
  • tests/tools/test_gitlab_file_tool.py
  • tests/tools/test_gitlab_mrs_tool.py
  • tests/tools/test_gitlab_pipelines_tool.py

Each file should:

  1. Contract test — inherit BaseToolContract from tests/tools/conftest.py
  2. is_availableTrue when sources["gitlab"] has token and project_id; False otherwise
  3. extract_params — assert the dict correctly maps project_id, token, gitlab_url from sources
  4. run happy path — patch the outgoing HTTP call (via unittest.mock.patch on the httpx or requests call inside app/integrations/gitlab.py) and verify the tool returns available: True with the expected output shape
  5. run error path — simulate a non-200 response or network error and verify a graceful error dict is returned

Acceptance criteria

  • All four test files created under tests/tools/
  • Each covers is_available, extract_params, and run (happy + error paths)
  • make test-cov passes
  • make lint passes

References

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerstestsTest coverage and test organization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions