File: test_validation.py

package info (click to toggle)
con-duct 0.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 608 kB
  • sloc: python: 4,332; sh: 22; makefile: 18
file content (41 lines) | stat: -rw-r--r-- 1,113 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import argparse
import pytest
from con_duct.__main__ import Arguments, assert_num


def test_sample_less_than_report_interval() -> None:
    args = Arguments.from_argv(
        ["fake"],
        sample_interval=0.01,
        report_interval=0.1,
    )
    assert args.sample_interval <= args.report_interval


def test_sample_equal_to_report_interval() -> None:
    args = Arguments.from_argv(
        ["fake"],
        sample_interval=0.1,
        report_interval=0.1,
    )
    assert args.sample_interval == args.report_interval


def test_sample_equal_greater_than_report_interval() -> None:
    with pytest.raises(argparse.ArgumentError):
        Arguments.from_argv(
            ["fake"],
            sample_interval=1.0,
            report_interval=0.1,
        )


@pytest.mark.parametrize("input_value", [0, 1, 2, -1, 100, 0.001, -1.68])
def test_assert_num_green(input_value: int) -> None:
    assert_num(input_value)


@pytest.mark.parametrize("input_value", ["hi", "0", "one"])
def test_assert_num_red(input_value: int) -> None:
    with pytest.raises(AssertionError):
        assert_num(input_value)