web/website/integrations/ops/test_shared_chrome.py
2026-11-21 20:22:37 +01:00

23 lines
1.1 KiB
Python

import importlib.util
from pathlib import Path
import unittest
source = Path(__file__).resolve().parents[2]/'scripts/install-shared-chrome.py'
spec = importlib.util.spec_from_file_location('shared_chrome',source)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
class SharedChrome(unittest.TestCase):
def test_aliases_follow_current_release_and_keep_headers(self):
text='location = /dune-navigation.js { alias '+module.LEGACY+'portal-navigation.js; add_header Content-Security-Policy "unchanged" always; }'
updated=module.rewrite_paths(text)
self.assertIn(module.CURRENT+'portal-navigation.js',updated)
self.assertIn('Content-Security-Policy "unchanged"',updated)
self.assertEqual(module.rewrite_paths(updated),updated)
self.assertEqual(module.rewrite_paths(updated,True),text)
def test_unrelated_paths_and_comments_are_preserved(self):
text='# '+module.LEGACY+'portal-navigation.js\nlocation /other { alias /private/keep; }'
self.assertEqual(module.rewrite_paths(text),text)
if __name__=='__main__':
unittest.main()