From a3d3571a20539aae13adcdb9cb863e2a4ad8b1d9 Mon Sep 17 00:00:00 2001 From: Justin Warren Date: Sun, 15 Jan 2023 10:10:52 +1100 Subject: [PATCH] Added basic tests of allowlist config args. --- tests/test_cmdline.py | 16 +++++++++++++++- tests/test_configfile.py | 11 +++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index ed63349..4e6f355 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -37,4 +37,18 @@ def test_cmdline_mergeplan_min(): ap = setup_argparse() args = ap.parse_args(['-m', 'min']) - assert args.mergeplan == 'min' \ No newline at end of file + assert args.mergeplan == 'min' + +def test_set_allow_domain(): + """Set a single allow domain on commandline""" + ap = setup_argparse() + args = ap.parse_args(['-A', 'example.org']) + + assert args.allow_domains == ['example.org'] + +def test_set_multiple_allow_domains(): + """Set multiple allow domains on commandline""" + ap = setup_argparse() + args = ap.parse_args(['-A', 'example.org', '-A', 'example2.org', '-A', 'example3.org']) + + assert args.allow_domains == ['example.org', 'example2.org', 'example3.org'] \ No newline at end of file diff --git a/tests/test_configfile.py b/tests/test_configfile.py index b6fb342..d52a425 100644 --- a/tests/test_configfile.py +++ b/tests/test_configfile.py @@ -45,3 +45,14 @@ def test_set_mergeplan_min(): assert args.mergeplan == 'min' +def test_set_allowlists(): + tomldata = """# Comment on config +allowlist_url_sources = [ { url='file:///path/to/allowlist', format='csv'} ] +""" + args = shim_argparse([], tomldata) + + assert args.mergeplan == 'max' + assert args.allowlist_url_sources == [{ + 'url': 'file:///path/to/allowlist', + 'format': 'csv', + }]