Add more tests for normalized host filter
authorIndrajit Raychaudhuri <redacted>
Sun, 9 Jul 2017 00:21:41 +0000 (19:21 -0500)
committerIndrajit Raychaudhuri <redacted>
Sun, 9 Jul 2017 00:52:30 +0000 (19:52 -0500)
testUpdateHostsFile.py

index 2eeac7be4e4727664efaf8843d6623314e3df3c2..c1f2e07dee635d3d59ae0b7614ac373772b86cc1 100644 (file)
@@ -141,7 +141,7 @@ class TestNormalizeRule(BaseStdout):
         kwargs = dict(target_ip="0.0.0.0", keep_domain_comments=False)
 
         for rule in ["foo", "128.0.0.1", "bar.com/usa", "0.0.0 google",
-                     "0.1.2.3.4 foo/bar", "twitter.com"]:
+                     "0.0.0.0 1.2.34.34", "0.1.2.3.4 foo/bar", "twitter.com"]:
             self.assertEqual(normalize_rule(rule, **kwargs), (None, None))
 
             output = sys.stdout.getvalue()
@@ -152,8 +152,8 @@ class TestNormalizeRule(BaseStdout):
 
     def test_no_comments(self):
         for target_ip in ("0.0.0.0", "127.0.0.1", "8.8.8.8"):
-            rule = "127.0.0.1 google foo"
-            expected = ("google", str(target_ip) + " google\n")
+            rule = "127.0.0.1 1.google.com foo"
+            expected = ("1.google.com", str(target_ip) + " 1.google.com\n")
 
             actual = normalize_rule(rule, target_ip=target_ip,
                                     keep_domain_comments=False)
@@ -168,9 +168,10 @@ class TestNormalizeRule(BaseStdout):
     def test_with_comments(self):
         for target_ip in ("0.0.0.0", "127.0.0.1", "8.8.8.8"):
             for comment in ("foo", "bar", "baz"):
-                rule = "127.0.0.1 google " + comment
-                expected = ("google", (str(target_ip) + " google # " +
-                                       comment + "\n"))
+                rule = "127.0.0.1 1.google.co.uk " + comment
+                expected = ("1.google.co.uk",
+                            (str(target_ip) + " 1.google.co.uk # " +
+                             comment + "\n"))
 
                 actual = normalize_rule(rule, target_ip=target_ip,
                                         keep_domain_comments=True)
git clone https://git.99rst.org/PROJECT