2023-01-11 20:02:48 +00:00
|
|
|
"""Tests of the Rapidblock CSV parsing
|
|
|
|
"""
|
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
from fediblockhole.blocklists import RapidBlockParserCSV, parse_blocklist
|
2023-01-11 20:02:48 +00:00
|
|
|
from fediblockhole.const import DomainBlock, BlockSeverity, SeverityLevel
|
|
|
|
|
|
|
|
csvdata = """example.org\r\nsubdomain.example.org\r\nanotherdomain.org\r\ndomain4.org\r\n"""
|
|
|
|
parser = RapidBlockParserCSV()
|
|
|
|
|
|
|
|
def test_basic_rapidblock():
|
|
|
|
|
|
|
|
bl = parser.parse_blocklist(csvdata)
|
|
|
|
assert len(bl) == 4
|
2023-01-16 22:04:34 +00:00
|
|
|
assert 'example.org' in bl
|
|
|
|
assert 'subdomain.example.org' in bl
|
|
|
|
assert 'anotherdomain.org' in bl
|
|
|
|
assert 'domain4.org' in bl
|
2023-01-11 20:02:48 +00:00
|
|
|
|
|
|
|
def test_severity_is_suspend():
|
|
|
|
bl = parser.parse_blocklist(csvdata)
|
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
for block in bl.values():
|
2023-01-11 20:02:48 +00:00
|
|
|
assert block.severity.level == SeverityLevel.SUSPEND
|