We create a default blocklist.yaml file that stores the blocked URLs. It can be edited with command line arguments.
save_config(default=True)
Read in the new config file:
blocklist = load_config()
blocklist
Testing add_urls
save_config(default=True)
assert "testsite.com" not in load_config(), "testsite.com should not be in default blocked URLs"
add_urls("testsite.com")
assert "testsite.com" in load_config(), "testsite.com should have been added to config file"
add_urls(["moresites.com", "CapitalLetters.COM"])
assert "moresites.com" in load_config(), "URL list should have been added to config file"
assert "capitalletters.com" in load_config(), "URLs should have been converted to lower case"
save_config(default=True)
Testing remove_urls
save_config(default=True)
assert "facebook.com" in load_config(), "facebook.com should be in default blocked URLs"
remove_urls("facebook.com")
assert "facebook.com" not in load_config(), "facebook.com should have been removed from config file"
remove_urls(["twitter.com", "YOUTUBE.COM"])
assert "twitter.com" not in load_config(), "URL list should have been removed from config file"
assert "youtube.com" not in load_config(), "URLs should have been converted to lower case"
save_config(default=True)