kiwi-el8/test/unit/api_helper_test.py
Marcus Schäfer 4bc7e3e77c
Added decorators to help with API management
The lifetime of API methods could be limited due to
the development of kiwi. To allow for a deprecation
process the following helper methods has been added
2021-01-31 16:06:35 +01:00

34 lines
857 B
Python

from pytest import raises
from 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)