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
|
######################################################################
#
# File: test/unit/utils/test_docs.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from __future__ import annotations
import pytest
from b2sdk._internal.raw_api import AbstractRawApi, LifecycleRule
from b2sdk._internal.utils.docs import MissingDocURL, ensure_b2sdk_doc_urls, get_b2sdk_doc_urls
def test_b2sdk_doc_urls():
@ensure_b2sdk_doc_urls
class MyCustomClass:
"""
This is a custom class with `Documentation URL`_.
.. _Documentation URL: https://example.com
"""
def test_b2sdk_doc_urls__no_urls_error():
with pytest.raises(MissingDocURL):
@ensure_b2sdk_doc_urls
class MyCustomClass:
pass
@pytest.mark.parametrize(
'type_,expected',
[
(AbstractRawApi, {}),
(
LifecycleRule,
{
'B2 Cloud Storage Lifecycle Rules': 'https://www.backblaze.com/docs/cloud-storage-lifecycle-rules',
},
),
],
)
def test_get_b2sdk_doc_urls(type_, expected):
assert get_b2sdk_doc_urls(type_) == expected
|