Skip to content

[TestProxy] Run test with testproxy for mgmt SDK

Yuchao Yan edited this page Feb 20, 2023 · 12 revisions

Getting Started - Run test with testproxy for mgmt SDK

Prerequisites

  • Python 3.7 or later is required

  • create virtual environment

    python -m venv venv
    .\venv-dev\Scripts\Activate.ps1
    
  • prepare SDK repo if needed

    git clone https://github.com/Azure/azure-sdk-for-python.git
    
  • prepare test proxy environment

How to Run Test

  • Setting environment variables (Powershell)

    run following command

    $env:AZURE_TENANT_ID="xxxxxxxxxxxxxxxx"
    $env:AZURE_CLIENT_ID="xxxxxxxxxxxxxxxx"
    $env:AZURE_CLIENT_SECRET="xxxxxxxxxxxxxxxx"
    $env:AZURE_SUBSCRIPTION_ID="xxxxxxxxxxxxxxxx"
    
  • Setting the necessary configuration

    1. Copy mgmt_settings_real_.py to tools\azure-sdk-tools\devtools_testutils and rename it to mgmt_settings_real.py

    2. Replace the ENV_SUBSCRIPTION_ID, ENV_CLIENT_ID, ENV_CLIENT_SECRET, ENV_TENANT_ID with available values in this file. (Note: some values appear multiple times and need to be replaced completely)

  • Preparation dependence

    Go to the directory for test. Like this: D:\azure-sdk-for-python\sdk\servicebus\azure-mgmt-servicebus

    And run command:

    pip install -r dev_requirements.txt
    pip install -e .
    
  • Then run test command like:

    (venv) D:\azure-sdk-for-python\sdk\servicebus\azure-mgmt-servicebus>pytest tests
    
  • Check the test results MicrosoftTeams-image (4)

  • Complete migration guide

    FYR: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md#guide-for-migrating-to-the-test-proxy-from-vcrpy