File: api_helper_test.py

package info (click to toggle)
kiwi 10.2.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,664 kB
  • sloc: python: 69,179; sh: 4,228; xml: 3,383; ansic: 391; makefile: 353
file content (33 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
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
from pytest import raises
from unittest.mock import patch
from kiwi.api_helper import (
    obsolete,
    decommissioned
)


@decommissioned
def method_decommissioned():
    # Implementation has been deleted
    pass


@obsolete(decommission_at='2025-01-28', version="1.2.3")
def method_obsolete():
    return 'I still exist'


class TestApiHelpers:
    def test_method_decommissioned(self):
        with raises(DeprecationWarning):
            method_decommissioned()

    @patch('warnings.warn')
    def test_method_obsolete(self, mock_warnings_warn):
        warning_message = (
            "Function 'method_obsolete' is marked obsolete "
            "since version '1.2.3' and will be decommissioned "
            "at: 2025-01-28"
        )
        assert method_obsolete() == 'I still exist'
        mock_warnings_warn.assert_called_once_with(warning_message)