File: test_client_unit.py

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (30 lines) | stat: -rw-r--r-- 1,019 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
import sys
import pytest
from unittest.mock import Mock
from devtools_testutils import AzureTestCase
from azure.core.exceptions import ServiceRequestError
from azure.core.credentials import AzureKeyCredential
from azure.maps.geolocation import MapsGeolocationClient


# cSpell:disable
def create_mock_client():
    return MapsGeolocationClient(credential= Mock(AzureKeyCredential))

class AzureMapsGeolocationClientUnitTest(AzureTestCase):
    def test_get_country_code(self):
        client = create_mock_client()
        with pytest.raises(ServiceRequestError):
            client.get_country_code(ip_address="12345123")


if __name__ == "__main__" :
    testArgs = [ "-v" , "-s" ] if len(sys.argv) == 1 else sys.argv[1:]
    #testArgs = [ "-s" , "-n" , "auto" , "--dist=loadscope" ] if len(sys.argv) == 1 else sys.argv[1:]
    #pytest-xdist: -n auto --dist=loadscope
    #pytest-parallel: --tests-per-worker auto
    #print( "testArgs={}".format(testArgs) )

    pytest.main(args=testArgs)

    print("main() Leave")