| 1 |
from pytest import raises |
| 2 |
from unittest.mock import patch |
| 3 |
from kiwi.api_helper import ( |
| 4 |
obsolete, |
| 5 |
decommissioned |
| 6 |
) |
| 7 |
|
| 8 |
|
| 9 |
@decommissioned |
| 10 |
def method_decommissioned(): |
| 11 |
# Implementation has been deleted |
| 12 |
pass |
| 13 |
|
| 14 |
|
| 15 |
@obsolete(decommission_at='2025-01-28', version="1.2.3") |
| 16 |
def method_obsolete(): |
| 17 |
return 'I still exist' |
| 18 |
|
| 19 |
|
| 20 |
class TestApiHelpers: |
| 21 |
def test_method_decommissioned(self): |
| 22 |
with raises(DeprecationWarning): |
| 23 |
method_decommissioned() |
| 24 |
|
| 25 |
@patch('warnings.warn') |
| 26 |
def test_method_obsolete(self, mock_warnings_warn): |
| 27 |
warning_message = ( |
| 28 |
"Function 'method_obsolete' is marked obsolete " |
| 29 |
"since version '1.2.3' and will be decommissioned " |
| 30 |
"at: 2025-01-28" |
| 31 |
) |
| 32 |
assert method_obsolete() == 'I still exist' |
| 33 |
mock_warnings_warn.assert_called_once_with(warning_message) |