aristanetworks / avd

Arista Validated Designs
https://avd.arista.com
Apache License 2.0
298 stars 219 forks source link

Test(cv_deploy): Add support for offline testing of CVClient #4744

Open ClausHolbechArista opened 3 days ago

ClausHolbechArista commented 3 days ago

Change Summary

Add support for offline testing of CVClient

Proposed changes

How to test

Added a pytest fixture which automatically serves the relevant type of CVClient:

@pytest_asyncio.fixture
async def cv_client() -> AsyncGenerator[CVClient, None]:
    """
    Instance of CVClient.

    If CVAAS_AAWG_CI environment variable is set, but RECORDING environment variable is not set,
    this will return a proper instance of CVClient connected to cv-staging with the token.

    If CVAAS_AAWG_CI environment variable is set, but RECORDING environment variable is set,
    this will return an instance of CVClient connected to cv-staging with the token where all API calls will be recorded.

    Otherwise this will return an instance of CVClient where API calls are mocked using previously recorded API messages.
    """

Checklist

User Checklist

Repository Checklist

github-actions[bot] commented 3 days ago

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4744
# Activate the virtual environment
source test-avd-pr-4744/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/ClausHolbechArista/avd.git@test/cv_workspace/pytest-mock-cv-api#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/ClausHolbechArista/avd.git#/ansible_collections/arista/avd/,test/cv_workspace/pytest-mock-cv-api --force
# Optional: Install AVD examples
cd test-avd-pr-4744
ansible-playbook arista.avd.install_examples
sonarcloud[bot] commented 3 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud