Skip to content

test: add unit tests for storage providers, webhooks, MCP registry, and fix silent skips - #30

Merged
OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
Maqbool61:feat/expand-test-coverage
Jul 20, 2026
Merged

OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
Maqbool61:feat/expand-test-coverage

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

Problem

Test coverage was narrow — no tests existed for s3_storage.py, gcs_storage.py, azure_storage.py, devops_mcp/registry.py, or any webhook/org-config route. docs/PLATFORM_SUPPORT.md referenced pytest tests/integration/ -v but tests/integration/ did not exist. Two tests used assert True stubs and several except Exception: pass blocks silently masked failures.

Closes #16.

Changes

tests/test_storage.py (new)

Mock-based tests for all three cloud storage providers using sys.modules injection so no real credentials or cloud SDKs are needed:

  • TestS3Storage — put_json, get_json, get_json missing key (with proper NoSuchKey exception class), list_keys sorted, delete exists/missing
  • TestGCSStorage — same operations via mocked google.cloud.storage.Client
  • TestAzureBlobStorage — same operations via mocked azure.storage.blob.BlobServiceClient

tests/test_api.py (new)

FastAPI TestClient tests with all external services mocked (DevOpsAgent, IncidentQueue, IncidentStore, OrgDocs, EscalationService):

  • GET /health → 200
  • GET /audit → 200
  • POST /webhook/github — valid WEBHOOK_SECRET signature → 200; invalid signature → 401; no secret configured → 200
  • POST /webhook/alertmanager — valid payload → 200; empty alerts → 200
  • POST /webhook/manual — with required type field → 200
  • POST/GET/DELETE /orgs/{org_id}/docs → 200
  • PUT /orgs/{org_id}/config → 200
  • GET /orgs/{org_id}/config/status → 200

tests/test_mcp.py (new)

  • test_agent_tools_are_defined — asserts AGENT_TOOLS is a non-empty list with name and description on every entry
  • test_register_agent_tools_registers_all_tools — mocks FastMCP and asserts mcp.add_tool is called exactly once per tool in AGENT_TOOLS with matching names

tests/test_basic.py (updated)

  • Replaced assert True in test_imports and two stub tests with pytest.skip() pointing to the new covering test files
  • Replaced bare except Exception: pass blocks in TestK8sCollector with pytest.skip() carrying an explicit reason
  • Replaced except Exception: pass in async health/audit tests with except ImportError: pytest.skip(...)

tests/integration/README.md (new)

Documents that integration tests require live credentials and a real Kubernetes cluster, and are not run in CI — satisfies the docs/PLATFORM_SUPPORT.md reference.

Test results

53 passed, 2 skipped in 0.96s

The 2 skips are the intentional pytest.skip() stubs for agent tool-call tests that require a live agent loop.

- tests/test_storage.py: mock-based tests for S3Storage, GCSStorage,
  and AzureBlobStorage covering put_json, get_json, list_keys, delete,
  and missing-key edge cases; no real cloud credentials required
- tests/test_api.py: FastAPI TestClient tests for /health, /audit,
  /webhook/github (valid sig, invalid sig, no secret), /webhook/alertmanager
  (valid payload, empty alerts), /webhook/manual, and /orgs/{org_id}/docs
  CRUD routes; all external services mocked
- tests/test_mcp.py: smoke tests asserting AGENT_TOOLS is non-empty and
  register_agent_tools registers every tool name via mcp.add_tool
- tests/test_basic.py: replace bare except/pass with pytest.skip(),
  replace assert True stubs with pytest.skip() pointing to test_mcp.py
- tests/integration/README.md: document that integration tests require
  live credentials and are not run in CI

Closes open-devops-agent#16

@OkiriGabriel OkiriGabriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Covers all acceptance criteria for #16 — storage mocks, API routes, MCP registry, test_basic fixes, and integration README. Nice work.

@OkiriGabriel

Copy link
Copy Markdown
Collaborator

Thanks @Maqbool61 — this covers all the acceptance criteria for #16. Approved workflow and review; will merge once CI is green. Good work on the storage mocks and MCP registry test.

@OkiriGabriel
OkiriGabriel merged commit 4bb6b5e into open-devops-agent:main Jul 20, 2026
11 checks passed
@Maqbool61
Maqbool61 deleted the feat/expand-test-coverage branch July 21, 2026 04:43
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.

Add unit tests for collectors, cloud storage, webhooks, and MCP

2 participants