File: test_utils.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 (39 lines) | stat: -rw-r--r-- 1,164 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
# The MIT License (MIT)
# Copyright (c) Microsoft Corporation. All rights reserved.

import platform
import unittest
import uuid

import azure.cosmos
import azure.cosmos._utils as _utils
import test_config
from azure.cosmos import CosmosClient


class TestsUtils(unittest.TestCase):
    """Utils Tests
    """

    def test_user_agent(self):
        user_agent = _utils.get_user_agent()

        expected_user_agent = "azsdk-python-cosmos/{} Python/{} ({})".format(
            azure.cosmos.__version__,
            platform.python_version(),
            platform.platform()
        )
        self.assertEqual(user_agent, expected_user_agent)

    def test_connection_string(self):
        client: CosmosClient = (azure.cosmos.CosmosClient
                                .from_connection_string(test_config.TestConfig.connection_str,
                                                        consistency_level="Session"))
        database_id = "connection_string_test" + str(uuid.uuid4())
        db = client.create_database(database_id)
        self.assertTrue(db is not None)
        client.delete_database(db.id)


if __name__ == "__main__":
    unittest.main()