File: testcase_async.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (38 lines) | stat: -rw-r--r-- 1,553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# coding: utf-8
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from azure.developer.loadtesting.aio import LoadTestRunClient, LoadTestAdministrationClient
from devtools_testutils import AzureRecordedTestCase


class LoadTestingAsyncTest(AzureRecordedTestCase):
    def create_administration_client(self, endpoint) -> LoadTestAdministrationClient:
        self.admin_credential = self.get_credential(LoadTestAdministrationClient, is_async=True)
        self.admin_client = self.create_client_from_credential(
            LoadTestAdministrationClient,
            credential=self.admin_credential,
            endpoint=endpoint,
        )
        
        return self.admin_client

    def create_run_client(self, endpoint) -> LoadTestRunClient:
        self.run_credential = self.get_credential(LoadTestRunClient, is_async=True)
        self.run_client = self.create_client_from_credential(
            LoadTestRunClient,
            credential=self.run_credential,
            endpoint=endpoint,
        )

        return self.run_client
    
    async def close_admin_client(self):
        await self.admin_credential.close()
        await self.admin_client.close()
    
    async def close_run_client(self):
        await self.run_credential.close()
        await self.run_client.close()