File: test_macro.py

package info (click to toggle)
zabbix-cli 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,860 kB
  • sloc: python: 18,557; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from __future__ import annotations

import pytest
from zabbix_cli.commands.macro import fmt_macro_name
from zabbix_cli.exceptions import ZabbixCLIError

MARK_FAIL = pytest.mark.xfail(raises=ZabbixCLIError, strict=True)


@pytest.mark.parametrize(
    "name, expected",
    [
        pytest.param("my_macro", "{$MY_MACRO}"),
        pytest.param("MY_MACRO", "{$MY_MACRO}"),
        pytest.param("mY_maCrO", "{$MY_MACRO}"),
        pytest.param("foo123", "{$FOO123}"),
        pytest.param(" ", "", marks=MARK_FAIL),
        pytest.param("", "", marks=MARK_FAIL),
        pytest.param("{$}", "", marks=MARK_FAIL),
    ],
)
def test_fmt_macro_name(name: str, expected: str) -> None:
    assert fmt_macro_name(name) == expected