summaryrefslogtreecommitdiff
path: root/tests/plugins/deprecationwarnings/deprecationwarnings.py
blob: 75652bf064b7e94ffc9ff28c0c5ba0f4fa2cb365 (plain)
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
import pytest
import os
from buildstream.testing import cli


DATA_DIR = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "project"
)

_DEPRECATION_MESSAGE = "Here is some detail."
_DEPRECATION_WARNING = "Using deprecated plugin deprecated_plugin: {}".format(_DEPRECATION_MESSAGE)


@pytest.mark.datafiles(DATA_DIR)
def test_deprecation_warning_present(cli, datafiles):
    project = str(datafiles)
    result = cli.run(project=project, args=['show', 'deprecated.bst'])
    result.assert_success()
    assert _DEPRECATION_WARNING in result.stderr


@pytest.mark.datafiles(DATA_DIR)
def test_suppress_deprecation_warning(cli, datafiles):
    project = str(datafiles)
    cli.run(project=project, args=['show', 'manual.bst'])

    element_overrides = "elements:\n" \
                        "  deprecated_plugin:\n" \
                        "    suppress-deprecation-warnings : True\n"

    project_conf = os.path.join(project, 'project.conf')
    with open(project_conf, 'a') as f:
        f.write(element_overrides)

    result = cli.run(project=project, args=['show', 'deprecated.bst'])
    result.assert_success()
    assert _DEPRECATION_WARNING not in result.stderr