Better name for is_valid_user_provided_domain_format.
authorSteven Black <redacted>
Mon, 26 Apr 2021 21:08:38 +0000 (17:08 -0400)
committerSteven Black <redacted>
Mon, 26 Apr 2021 21:08:38 +0000 (17:08 -0400)
testUpdateHostsFile.py
updateHostsFile.py

index c78bb8ada956f9b6f8b8bebdacd851d9d87c207a..d93028d6dbfbe9c59a9f193b3d2ceb1e08f4e8e7 100644 (file)
@@ -30,7 +30,7 @@ from updateHostsFile import (
     gather_custom_exclusions,
     get_defaults,
     get_file_by_url,
-    is_valid_domain_format,
+    is_valid_user_provided_domain_format,
     matches_exclusions,
     move_hosts_file_into_place,
     normalize_rule,
@@ -125,7 +125,7 @@ class TestGetDefaults(Base):
                 "readmedata": {},
                 "readmedatafilename": ("foo" + self.sep + "readmeData.json"),
                 "exclusionpattern": r"([a-zA-Z\d-]+\.){0,}",
-                "exclusionregexs": [],
+                "exclusionregexes": [],
                 "exclusions": [],
                 "commonexclusions": ["hulu.com"],
                 "blacklistfile": "foo" + self.sep + "blacklist",
@@ -543,7 +543,7 @@ class TestGatherCustomExclusions(BaseStdout):
     # Can only test in the invalid domain case
     # because of the settings global variable.
     @mock.patch("updateHostsFile.input", side_effect=["foo", "no"])
-    @mock.patch("updateHostsFile.is_valid_domain_format", return_value=False)
+    @mock.patch("updateHostsFile.is_valid_user_provided_domain_format", return_value=False)
     def test_basic(self, *_):
         gather_custom_exclusions("foo", [])
 
@@ -552,7 +552,7 @@ class TestGatherCustomExclusions(BaseStdout):
         self.assertIn(expected, output)
 
     @mock.patch("updateHostsFile.input", side_effect=["foo", "yes", "bar", "no"])
-    @mock.patch("updateHostsFile.is_valid_domain_format", return_value=False)
+    @mock.patch("updateHostsFile.is_valid_user_provided_domain_format", return_value=False)
     def test_multiple(self, *_):
         gather_custom_exclusions("foo", [])
 
@@ -1753,9 +1753,9 @@ class TestQueryYesOrNo(BaseStdout):
         self.assertIn(expected, output)
 
 
-class TestIsValidDomainFormat(BaseStdout):
+class TestIsValidUserProvidedDomainFormat(BaseStdout):
     def test_empty_domain(self):
-        self.assertFalse(is_valid_domain_format(""))
+        self.assertFalse(is_valid_user_provided_domain_format(""))
 
         output = sys.stdout.getvalue()
         expected = "You didn't enter a domain. Try again."
@@ -1770,7 +1770,7 @@ class TestIsValidDomainFormat(BaseStdout):
             "https://github.com",
             "http://www.google.com",
         ]:
-            self.assertFalse(is_valid_domain_format(invalid_domain))
+            self.assertFalse(is_valid_user_provided_domain_format(invalid_domain))
 
             output = sys.stdout.getvalue()
             sys.stdout = StringIO()
@@ -1779,7 +1779,7 @@ class TestIsValidDomainFormat(BaseStdout):
 
     def test_valid_domain(self):
         for valid_domain in ["github.com", "travis.org", "twitter.com"]:
-            self.assertTrue(is_valid_domain_format(valid_domain))
+            self.assertTrue(is_valid_user_provided_domain_format(valid_domain))
 
             output = sys.stdout.getvalue()
             sys.stdout = StringIO()
index 66a7338dd5e64ca8afb951d613cbdbb3b710b823..3656c5f719e30e72e27bb87724b86b5749fcf263 100644 (file)
@@ -571,7 +571,7 @@ def gather_custom_exclusions(exclusion_pattern, exclusion_regexes):
         domain_prompt = "Enter the domain you want to exclude (e.g. facebook.com): "
         user_domain = input(domain_prompt)
 
-        if is_valid_domain_format(user_domain):
+        if is_valid_user_provided_domain_format(user_domain):
             exclusion_regexes = exclude_domain(
                 user_domain, exclusion_pattern, exclusion_regexes
             )
@@ -1612,7 +1612,7 @@ def query_yes_no(question, default="yes"):
     return reply == "yes"
 
 
-def is_valid_domain_format(domain):
+def is_valid_user_provided_domain_format(domain):
     """
     Check whether a provided domain is valid.
 
git clone https://git.99rst.org/PROJECT