File: logger_test.py

package info (click to toggle)
cdsetool 0.2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: python: 1,197; xml: 97; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download
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
39
40
41
import pytest
from unittest.mock import MagicMock

from cdsetool.logger import NoopLogger
from cdsetool.download import download_feature


def test_noop_logger_is_default() -> None:
    NoopLogger.debug = MagicMock()

    assert NoopLogger.debug.call_count == 0

    download_feature(
        {
            "bad_object": True,
            "properties": {
                "title": "myfile.xml",
                "services": {"download": {}},  # missing url
            },
        },
        "somewhere",
    )

    assert NoopLogger.debug.call_count == 1


def test_noop_does_not_error() -> None:
    try:
        download_feature(
            {
                "bad_object": True,
                "properties": {
                    "title": "myfile.xml",
                    "services": {"download": {}},  # missing url
                },
            },
            "somewhere",
        )
        NoopLogger().debug("NoopLogger did not raise an exception")
    except Exception as e:
        pytest.fail(f"Unexpected exception: {e}")