From ce98261d484d4d4129d1a1731113642313ac532b Mon Sep 17 00:00:00 2001 From: Justin Warren Date: Tue, 17 Jan 2023 06:52:25 +1100 Subject: [PATCH] Fix typos in test_allowlist. Added test of TLD allowlisting. --- tests/test_allowlist.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/test_allowlist.py b/tests/test_allowlist.py index e632361..902b301 100644 --- a/tests/test_allowlist.py +++ b/tests/test_allowlist.py @@ -13,7 +13,7 @@ def test_cmdline_allow_removes_domain(): merged = { 'example.org': DomainBlock('example.org'), - 'example2.org': DomainBlock('example.org'), + 'example2.org': DomainBlock('example2.org'), 'removeme.org': DomainBlock('removeme.org'), 'keepblockingme.org': DomainBlock('keepblockingme.org'), } @@ -34,7 +34,7 @@ def test_allowlist_removes_domain(): merged = { 'example.org': DomainBlock('example.org'), - 'example2.org': DomainBlock('example.org'), + 'example2.org': DomainBlock('example2.org'), 'removeme.org': DomainBlock('removeme.org'), 'keepblockingme.org': DomainBlock('keepblockingme.org'), } @@ -47,3 +47,30 @@ def test_allowlist_removes_domain(): with pytest.raises(KeyError): merged['removeme.org'] + +def test_allowlist_removes_tld(): + """Test that an item in an allowlist removes entries from merged + """ + conf = shim_argparse() + + merged = { + '.cf': DomainBlock('.cf'), + 'example.org': DomainBlock('example.org'), + '.tk': DomainBlock('.tk'), + 'keepblockingme.org': DomainBlock('keepblockingme.org'), + } + + allowlists = { + 'list1': [ + DomainBlock('.cf', 'noop'), + DomainBlock('.tk', 'noop'), + ] + } + + merged = apply_allowlists(merged, conf, allowlists) + + with pytest.raises(KeyError): + merged['.cf'] + + with pytest.raises(KeyError): + merged['.tk'] \ No newline at end of file