File: test_metadata.py

package info (click to toggle)
tina 0.1.14-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 920 kB
  • sloc: ansic: 1,653; sh: 1,415; python: 1,189; makefile: 42
file content (51 lines) | stat: -rw-r--r-- 1,328 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
42
43
44
45
46
47
48
49
50
51
# SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
# SPDX-License-Identifier: GPL-2.0-or-later
"""Test some simple conversions between formats."""

from __future__ import annotations

import subprocess  # noqa: S404
import typing

import pytest

from unit import util as t_util

from . import util as tc_util


if typing.TYPE_CHECKING:
    from typing import Final


@pytest.mark.parametrize(
    "opts",
    [["-h"], ["--help"], ["-V"], ["--version"], ["-h", "--version"], ["-V", "--help"]],
)
def test_help_version(*, opts: list[str]) -> None:
    """Make sure the `--help` and `--version` options do not raise errors."""
    print()
    prog: Final = t_util.get_prog_path(t_util.ProgramType.CONVERT)

    assert opts
    res: Final = subprocess.run(  # noqa: S603
        [prog, *opts],
        capture_output=True,
        check=False,
        encoding="UTF-8",
        env=t_util.get_utf8_env(),
    )
    print(repr(res))
    assert res.returncode == 0
    assert res.stdout
    assert not res.stderr


def test_list_formats() -> None:
    """Make sure `tina-convert list formats` outputs something sensible."""
    print()
    prog: Final = t_util.get_prog_path(t_util.ProgramType.CONVERT)

    formats: Final = tc_util.list_formats(prog)
    for expected in ("tina", "json"):
        assert expected in formats