aboutsummaryrefslogtreecommitdiffstats
path: root/package/button-hotplug/src/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'package/button-hotplug/src/Makefile')
0 files changed, 0 insertions, 0 deletions
n73'>73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
from unittest import mock

from pathod import pathod_cmdline as cmdline


def test_parse_anchor_spec():
    assert cmdline.parse_anchor_spec("foo=200") == ("foo", "200")
    assert cmdline.parse_anchor_spec("foo") is None


@mock.patch("argparse.ArgumentParser.error")
def test_pathod(perror, tdata):
    assert cmdline.args_pathod(["pathod"])

    a = cmdline.args_pathod(
        [
            "pathod",
            "--cert",
            tdata.path("pathod/data/testkey.pem")
        ]
    )
    assert a.ssl_certs

    a = cmdline.args_pathod(
        [
            "pathod",
            "--cert",
            "nonexistent"
        ]
    )
    assert perror.called
    perror.reset_mock()

    a = cmdline.args_pathod(
        [
            "pathod",
            "-a",
            "foo=200"
        ]
    )
    assert a.anchors

    a = cmdline.args_pathod(
        [
            "pathod",
            "-a",
            "foo=" + tdata.path("pathod/data/response")
        ]
    )
    assert a.anchors

    a = cmdline.args_pathod(
        [
            "pathod",
            "-a",
            "?=200"
        ]
    )
    assert perror.called
    perror.reset_mock()

    a = cmdline.args_pathod(
        [
            "pathod",
            "-a",
            "foo"
        ]
    )
    assert perror.called
    perror.reset_mock()

    a = cmdline.args_pathod(
        [
            "pathod",
            "--limit-size",
            "200k"
        ]
    )
    assert a.sizelimit

    a = cmdline.args_pathod(
        [
            "pathod",
            "--limit-size",
            "q"
        ]
    )
    assert perror.called
    perror.reset_mock()