File tree Expand file tree Collapse file tree 3 files changed +19
-13
lines changed
Expand file tree Collapse file tree 3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 88
99class FileHashedNameMixin :
1010 default_excluded_patterns = ["leaflet/*/*.png" ]
11- excluded_patterns = default_excluded_patterns + getattr (
12- settings , "OPENWISP_STATICFILES_VERSIONED_EXCLUDE" , []
13- )
11+
12+ @property
13+ def excluded_patterns (self ):
14+ return self .default_excluded_patterns + getattr (
15+ settings , "OPENWISP_STATICFILES_VERSIONED_EXCLUDE" , []
16+ )
1417
1518 def hashed_name (self , name , content = None , filename = None ):
1619 if not any (
Original file line number Diff line number Diff line change @@ -292,9 +292,10 @@ def test_stacked_inline_help_text(self):
292292 response , "Only added operators will have permission to access the project."
293293 )
294294 self .assertContains (response , "https://github.com/openwisp/openwisp-utils/" )
295- # Response should contain static in 'icon_url'
296- self .assertContains (
297- response , '<img src="/static/admin/img/icon-alert.svg">' , html = True
295+ # Response should contain static icon-alert image (with or without hash)
296+ self .assertRegex (
297+ response .content .decode (),
298+ r'<img src="/static/admin/img/icon-alert(\.[a-f0-9]+)?\.svg">' ,
298299 )
299300
300301 def test_admin_theme_css_setting (self ):
@@ -358,10 +359,10 @@ def test_admin_theme_static_backward_compatible(self):
358359 self .assertEqual (
359360 _staticfy ("admin/css/openwisp.css" ), "admin/css/openwisp.css"
360361 )
361- # test static files are loaded with staticfiles
362- self . assertEqual (
363- _staticfy ( "admin/css/openwisp.css" ), " /static/admin/css/openwisp.css"
364- )
362+ # test static files are loaded with staticfiles (may include hash and .min)
363+ result = _staticfy ( "admin/css/openwisp.css" )
364+ self . assertTrue ( result . startswith ( " /static/admin/css/openwisp." ))
365+ self . assertTrue ( result . endswith ( ".css" ) )
365366
366367 def test_admin_theme_js_setting (self ):
367368 # test for improper configuration : not a list
Original file line number Diff line number Diff line change @@ -214,11 +214,13 @@ def test_index_content(self):
214214 self .assertContains (
215215 response , '<div style="display:none">Testing dashboard</div>'
216216 )
217- self .assertContains (response , "dashboard-test.js" )
218- self .assertContains (response , "dashboard-test.css" )
217+ # Check for dashboard-test files (may have hash and .min suffix)
218+ self .assertRegex (response .content .decode (), r'dashboard-test(\.[a-f0-9]+)?(\.min)?\.js' )
219+ self .assertRegex (response .content .decode (), r'dashboard-test(\.[a-f0-9]+)?(\.min)?\.css' )
219220 self .assertContains (response , "dashboard-test.config1" )
220221 self .assertContains (response , "dashboard-test.config2" )
221- self .assertContains (response , "jquery.init.js" )
222+ # Check for jquery.init (may have hash and .min suffix)
223+ self .assertRegex (response .content .decode (), r'jquery\.init(\.[a-f0-9]+)?(\.min)?\.js' )
222224 self .assertContains (response , "Operator presence in projects" )
223225 self .assertContains (response , "with_operator" )
224226 self .assertContains (response , "without_operator" )
You can’t perform that action at this time.
0 commit comments