From 18a4456397d0b4b1275ac2c8ab393d041176e949 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Mon, 8 Jun 2015 16:03:33 +0200 Subject: refactor cmdline tests --- test/test_pathod_cmdline.py | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 test/test_pathod_cmdline.py (limited to 'test/test_pathod_cmdline.py') diff --git a/test/test_pathod_cmdline.py b/test/test_pathod_cmdline.py new file mode 100644 index 00000000..590bb56b --- /dev/null +++ b/test/test_pathod_cmdline.py @@ -0,0 +1,104 @@ +from libpathod import pathod_cmdline as cmdline +import tutils +import cStringIO +import mock + + +@mock.patch("argparse.ArgumentParser.error") +def test_pathod(perror): + assert cmdline.args_pathod(["pathod"]) + + a = cmdline.args_pathod( + [ + "pathod", + "--cert", + tutils.test_data.path("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=" + tutils.test_data.path("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() + + s = cStringIO.StringIO() + tutils.raises( + SystemExit, + cmdline.args_pathod, + ["pathod", "-a", "foo=."], + s, + s + ) + + 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() + + a = cmdline.args_pathod( + [ + "pathod", + "-c", + "?" + ] + ) + assert perror.called + perror.reset_mock() -- cgit v1.2.3 From 30fbf57e4b72e3947c323d98aee7b2d44663e33c Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Fri, 12 Jun 2015 13:41:04 +0200 Subject: delay pathod parsing until needed This allows us to use different languages based on runtime env. --- test/test_pathod_cmdline.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'test/test_pathod_cmdline.py') diff --git a/test/test_pathod_cmdline.py b/test/test_pathod_cmdline.py index 590bb56b..829c4b32 100644 --- a/test/test_pathod_cmdline.py +++ b/test/test_pathod_cmdline.py @@ -65,15 +65,6 @@ def test_pathod(perror): assert perror.called perror.reset_mock() - s = cStringIO.StringIO() - tutils.raises( - SystemExit, - cmdline.args_pathod, - ["pathod", "-a", "foo=."], - s, - s - ) - a = cmdline.args_pathod( [ "pathod", @@ -92,13 +83,3 @@ def test_pathod(perror): ) assert perror.called perror.reset_mock() - - a = cmdline.args_pathod( - [ - "pathod", - "-c", - "?" - ] - ) - assert perror.called - perror.reset_mock() -- cgit v1.2.3