File: test_base_unit.py

package info (click to toggle)
python-azure 20251014%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 766,472 kB
  • sloc: python: 6,314,744; ansic: 804; javascript: 287; makefile: 198; sh: 198; xml: 109
file content (25 lines) | stat: -rw-r--r-- 830 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
# The MIT License (MIT)
# Copyright (c) Microsoft Corporation. All rights reserved.

import unittest

import pytest

import azure.cosmos._base as base


@pytest.mark.cosmosEmulator
class TestIdAndNameBased(unittest.TestCase):
    def test_is_name_based(self):
        self.assertFalse(base.IsNameBased("dbs/xjwmAA==/"))

        # This is a database name that ran into 'Incorrect padding'
        # exception within base.IsNameBased function
        self.assertTrue(base.IsNameBased("dbs/paas_cmr"))

    def test_collection_id(self):
        # correctly formatted link
        assert base.GetResourceIdOrFullNameFromLink("dbs/xjwmAA==/colls/1234") == "1234"
        # incorrectly formatted link should raise ValueError
        with pytest.raises(ValueError):
            base.GetResourceIdOrFullNameFromLink("db/xjwmAA==/coll/")