Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Jan 10, 2019
1 parent 6f0563d commit df7489f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ckan/lib/webassets_tools.py
Expand Up @@ -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()
}
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ckan/tests/test_none_root.py
Expand Up @@ -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')
5 changes: 3 additions & 2 deletions ckanext/textview/tests/test_view.py
Expand Up @@ -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)

0 comments on commit df7489f

Please sign in to comment.