From df7489f6ddfd80d55ec89d2406a7600cb935ddab Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Thu, 10 Jan 2019 16:33:41 +0200 Subject: [PATCH] Test fixes --- ckan/lib/webassets_tools.py | 8 +++++--- ckan/tests/test_none_root.py | 2 +- ckanext/textview/tests/test_view.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ckan/lib/webassets_tools.py b/ckan/lib/webassets_tools.py index f0c6a86fc94..ec3ec63447b 100644 --- a/ckan/lib/webassets_tools.py +++ b/ckan/lib/webassets_tools.py @@ -23,7 +23,7 @@ def create_library(name, path): library = YAMLLoader(config_path).load_bundles() bundles = { - '/'.join([name, key]): bundle + u'/'.join([name, key]): bundle for key, bundle in library.items() } @@ -45,7 +45,7 @@ def webassets_init(): public = config.get(u'ckan.base_public_folder') public_folder = os.path.abspath(os.path.join( - os.path.dirname(__file__), '..', public)) + os.path.dirname(__file__), u'..', public)) base_path = os.path.join(public_folder, u'base') static_path = os.path.join(public_folder, u'webassets') @@ -73,6 +73,7 @@ def _make_asset_collection(): def include_asset(name): + from ckan.lib.helpers import url_for_static_or_external try: if not g.webassets: raise AttributeError(u'WebAssets not initialized yet') @@ -98,7 +99,8 @@ def include_asset(name): for dep in deps: include_asset(dep) - urls = bundle.urls() + # Add `site_root` if configured + urls = [url_for_static_or_external(url) for url in bundle.urls()] type_ = None for url in urls: link = url.split(u'?')[0] diff --git a/ckan/tests/test_none_root.py b/ckan/tests/test_none_root.py index 086fc234dea..3c6b85ac5c7 100644 --- a/ckan/tests/test_none_root.py +++ b/ckan/tests/test_none_root.py @@ -12,5 +12,5 @@ def test_resource_url(self): content = app.get(u'/en/base.html') if u'example_theme.css' not in content: assert u'example_theme.min.css' in content - assert u'href="/data/fanstatic/example_theme' in content + assert u'href="/data/webassets/example_theme' in content p.unload(u'example_theme_v15_fanstatic') diff --git a/ckanext/textview/tests/test_view.py b/ckanext/textview/tests/test_view.py index 775ab2bf70a..87cd7423606 100644 --- a/ckanext/textview/tests/test_view.py +++ b/ckanext/textview/tests/test_view.py @@ -105,8 +105,9 @@ def test_js_included(self): id=self.package.name, resource_id=self.resource_id, view_id=self.resource_view['id']) result = app.get(url) - assert (('text_view.js' in result.body) or - ('text_view.min.js' in result.body)) + print(result.body) + assert (('text_view.js' in result.body) or # Source file + ('textview.js' in result.body)) # Compiled file # Restore the config to its original values config.clear() config.update(original_config)