clarifai-python icon indicating copy to clipboard operation
clarifai-python copied to clipboard

Add tests for local-dev CLI and config utilities

Open Copilot opened this issue 9 months ago • 0 comments

This PR adds comprehensive tests for:

  1. The local_dev CLI command which was added in PR #568
  2. The config.py utilities, specifically the Context and Config classes

Tests Added

For local_dev CLI:

  • Created test_local_dev_utils.py helper module with functions that test the core functionality without CLI dependencies
  • Added tests for various scenarios:
    • When all resources exist (compute cluster, nodepool, runner)
    • When compute cluster exists but runner doesn't exist
    • When compute cluster exists but nodepool doesn't exist
    • When compute cluster doesn't exist

For config.py:

  • Created tests/test_config.py with comprehensive tests for:
    • Context class:
      • Initialization with env parameter and kwargs
      • Get/set/delete attributes
      • Environment variable handling
      • Serialization to dict
      • Setting environment variables
    • Config class:
      • Loading from YAML
      • Serialization to dict and YAML
      • Current context property
      • Post-initialization processing

Implementation Approach

For the local_dev CLI tests, I avoided directly using the Click command infrastructure which would require significantly more mocking and complexity. Instead, I created utility functions that test the core logic directly, ensuring we verify that the function's behavior is correct for various scenarios.

The config.py tests are traditional unit tests that verify the functionality of the various methods and properties of the Context and Config classes.

Fixes #590.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.test.com
    • Triggering command: python -m pytest tests/cli/test_compute_orchestration.py::TestLocalDevCLI -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar May 22 '25 01:05 Copilot