File: test_lifecycle.py

package info (click to toggle)
cloud-init 25.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,412 kB
  • sloc: python: 135,894; sh: 3,883; makefile: 141; javascript: 30; xml: 22
file content (32 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (3)
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
import logging

import pytest

from cloudinit import lifecycle

LOG = logging.getLogger()


class TestLogWithDowngradableLevel:
    @pytest.mark.parametrize(
        "version,expected",
        [
            ("9", logging.ERROR),
            ("11", logging.DEBUG),
        ],
    )
    def test_log_with_downgradable_level(
        self, mocker, caplog, version, expected
    ):
        mocker.patch("cloudinit.features.DEPRECATION_INFO_BOUNDARY", "10")
        lifecycle.log_with_downgradable_level(
            logger=LOG,
            version=version,
            requested_level=logging.ERROR,
            msg="look at me %s %s!",
            args=("one", "two"),
        )
        records = caplog.record_tuples
        assert len(records) == 1
        assert records[0][1] == expected
        assert records[0][2] == "look at me one two!"