|
| 1 | +# The MIT License (MIT) |
| 2 | +# Copyright (c) 2021 Microsoft Corporation |
| 3 | + |
| 4 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | +# of this software and associated documentation files (the "Software"), to deal |
| 6 | +# in the Software without restriction, including without limitation the rights |
| 7 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | +# copies of the Software, and to permit persons to whom the Software is |
| 9 | +# furnished to do so, subject to the following conditions: |
| 10 | + |
| 11 | +# The above copyright notice and this permission notice shall be included in all |
| 12 | +# copies or substantial portions of the Software. |
| 13 | + |
| 14 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 | +# SOFTWARE. |
| 21 | + |
| 22 | +import unittest |
| 23 | + |
| 24 | +import azure.cosmos.cosmos_client as cosmos_client |
| 25 | +import pytest |
| 26 | +from test_config import _test_config |
| 27 | + |
| 28 | + |
| 29 | +# This test class serves to test user-configurable options and verify they are |
| 30 | +# properly set and saved into the different object instances that use these |
| 31 | +# user-configurable settings. |
| 32 | + |
| 33 | +pytestmark = pytest.mark.cosmosEmulator |
| 34 | + |
| 35 | +@pytest.mark.usefixtures("teardown") |
| 36 | +class TestUserConfigs(unittest.TestCase): |
| 37 | + |
| 38 | + def test_enable_endpoint_discovery(self): |
| 39 | + client_false = cosmos_client.CosmosClient(url=_test_config.host, credential=_test_config.masterKey, |
| 40 | + enable_endpoint_discovery=False) |
| 41 | + client_default = cosmos_client.CosmosClient(url=_test_config.host, credential=_test_config.masterKey) |
| 42 | + client_true = cosmos_client.CosmosClient(url=_test_config.host, credential=_test_config.masterKey, |
| 43 | + enable_endpoint_discovery=True) |
| 44 | + |
| 45 | + self.assertFalse(client_false.client_connection.connection_policy.EnableEndpointDiscovery) |
| 46 | + self.assertTrue(client_default.client_connection.connection_policy.EnableEndpointDiscovery) |
| 47 | + self.assertTrue(client_true.client_connection.connection_policy.EnableEndpointDiscovery) |
| 48 | + |
| 49 | +if __name__ == "__main__": |
| 50 | + unittest.main() |
0 commit comments