44from dynamic_breadcrumbs import app_settings
55from django .conf import settings
66from django .http import HttpResponse , HttpRequest
7+ from dynamic_breadcrumbs import app_settings
78
8- @override_settings (ALLOWED_HOSTS = "www.example.com" )
9+ @override_settings (ALLOWED_HOSTS = [ "www.example.com" ] )
910class SanitizeUrlTests (TestCase ):
1011
1112 def test_sanitize_base_urls_host_in_allowed_hosts_keeps_url (self ):
@@ -22,13 +23,29 @@ def test_sanitize_base_urls_host_not_in_allowed_hosts_returns_empty_string(self)
2223
2324 self .assertEqual (result , "" )
2425
25- # class ValidatePathTests(GenericModelTestCase):
26- # def test_sanitize_base_urls_host_in_allowed_hosts_keeps_url(self):
27- # path= f"https://{settings.ALLOWED_HOSTS[0]}"
26+ class ValidatePathTests (TestCase ):
27+ def test_validate_path_not_string_returns_empty_string (self ):
28+ path = 3.1416
29+
30+ result = validate_path (path = path )
31+
32+ self .assertEqual (result , "" )
33+
34+ def test_validate_path_check_alphanumeric_returns_empty_string (self ):
35+ app_settings .PATH_ALPHANUMERIC = True
36+ path = "*%#$@@#*(/%#%_)*"
37+
38+ result = validate_path (path = path )
39+
40+ self .assertEqual (result , "" )
41+
42+ def test_validate_path_non_check_alphanumeric_returns_path (self ):
43+ app_settings .PATH_ALPHANUMERIC = False
44+ path = "*%#$@@#*(/%#%_)*"
2845
29- # result = sanitize_url(url=base_url )
46+ result = validate_path ( path = path )
3047
31- # self.assertEqual(result, base_url )
48+ self .assertEqual (result , path )
3249
3350
3451class BreadcrumbsTests (TestCase ):
0 commit comments