import unittest from adlist.cache import cache_headers from adlist.validation import convert_host_line, validate_ip, validate_and_normalize_url class ValidationAndCacheTests(unittest.TestCase): def test_hosts_format(self): self.assertEqual(convert_host_line('0.0.0.0 ads.example.com', '127.0.0.1'), '127.0.0.1 ads.example.com') def test_adguard_format(self): self.assertEqual(convert_host_line('||tracking.example.com^', '0.0.0.0'), '0.0.0.0 tracking.example.com') def test_dnsmasq_format(self): self.assertEqual(convert_host_line('address=/block.example.com/0.0.0.0', '0.0.0.0'), '0.0.0.0 block.example.com') def test_plain_domains(self): self.assertEqual(convert_host_line('tracking.example.com', '::'), ':: tracking.example.com') def test_comments_ignored(self): self.assertIsNone(convert_host_line('# comment', '0.0.0.0')) def test_malformed_domains_ignored(self): self.assertIsNone(convert_host_line('a