File: test_queue_api_version.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 (62 lines) | stat: -rw-r--r-- 2,592 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

import pytest
from azure.storage.queue import QueueClient, QueueServiceClient
from azure.storage.queue._shared.constants import X_MS_VERSION

from devtools_testutils.storage import StorageRecordedTestCase


# ------------------------------------------------------------------------------

class TestStorageClient(StorageRecordedTestCase):
    def setUp(self):
        self.api_version_1 = "2019-02-02"
        self.api_version_2 = X_MS_VERSION

    # --Test Cases--------------------------------------------------------------

    def test_service_client_api_version_property(self):
        self.setUp()
        service_client = QueueServiceClient(
            "https://foo.queue.core.windows.net/account",
            credential="fake_key")
        assert service_client.api_version == self.api_version_2
        assert service_client._client._config.version == self.api_version_2

        with pytest.raises(AttributeError):
            service_client.api_version = "foo"

        service_client = QueueServiceClient(
            "https://foo.queue.core.windows.net/account",
            credential="fake_key",
            api_version=self.api_version_1)
        assert service_client.api_version == self.api_version_1
        assert service_client._client._config.version == self.api_version_1

        queue_client = service_client.get_queue_client("foo")
        assert queue_client.api_version == self.api_version_1
        assert queue_client._client._config.version == self.api_version_1

    def test_queue_client_api_version_property(self):
        self.setUp()
        queue_client = QueueClient(
            "https://foo.queue.core.windows.net/account",
            "queue_name",
            credential="fake_key",
            api_version=self.api_version_1)
        assert queue_client.api_version == self.api_version_1
        assert queue_client._client._config.version == self.api_version_1

        queue_client = QueueClient(
            "https://foo.queue.core.windows.net/account",
            "queue_name",
            credential="fake_key")
        assert queue_client.api_version == self.api_version_2
        assert queue_client._client._config.version == self.api_version_2

# ------------------------------------------------------------------------------