- {% set type = 'asset' %}
- {% include 'validation/snippets/validation_style_' ~ type ~ '.html' %}
+ {% asset 'ckanext-validation/main-css' %}
{% endblock %}
diff --git a/ckanext/validation/templates/package/snippets/resource_item.html b/ckanext/validation/templates/package/snippets/resource_item.html
index 4377863c..d5baef7c 100644
--- a/ckanext/validation/templates/package/snippets/resource_item.html
+++ b/ckanext/validation/templates/package/snippets/resource_item.html
@@ -4,8 +4,6 @@
{{ super() }}
{{ h.get_validation_badge(res, in_listing=True)|safe }}
-{% set type = 'asset' %}
-{% include 'validation/snippets/validation_style_' ~ type ~ '.html' %}
-{% endblock %}
-
+ {% asset 'ckanext-validation/main-css' %}
+{% endblock %}
diff --git a/ckanext/validation/templates/scheming/form_snippets/resource_schema.html b/ckanext/validation/templates/scheming/form_snippets/resource_schema.html
index 4f4c2c99..c69d6bf0 100644
--- a/ckanext/validation/templates/scheming/form_snippets/resource_schema.html
+++ b/ckanext/validation/templates/scheming/form_snippets/resource_schema.html
@@ -64,7 +64,6 @@
{% set existing_value = h.scheming_display_json_value(value, indent=None) if is_json else value %}
- {% set type = 'asset' %}
- {% include 'validation/snippets/validation_resource-schema-form_' ~ type ~ '.html' %}
+ {% asset 'ckanext-validation/resource-schema-form' %}
diff --git a/ckanext/validation/templates/validation/snippets/validation_report_asset.html b/ckanext/validation/templates/validation/snippets/validation_report_asset.html
deleted file mode 100644
index 987d4e97..00000000
--- a/ckanext/validation/templates/validation/snippets/validation_report_asset.html
+++ /dev/null
@@ -1,3 +0,0 @@
-{% asset 'ckanext-validation/goodtables-ui' %}
-{% asset 'ckanext-validation/validation-report-css' %}
-{% asset 'ckanext-validation/module-validation-report' %}
diff --git a/ckanext/validation/templates/validation/snippets/validation_report_dialog.html b/ckanext/validation/templates/validation/snippets/validation_report_dialog.html
index de6bcd01..33f64e6d 100644
--- a/ckanext/validation/templates/validation/snippets/validation_report_dialog.html
+++ b/ckanext/validation/templates/validation/snippets/validation_report_dialog.html
@@ -14,5 +14,8 @@
-{% set type = 'asset' %}
-{% include 'validation/snippets/validation_report_form_' ~ type ~ '.html' %}
+{% asset 'ckanext-validation/goodtables-ui' %}
+{% asset 'ckanext-validation/validation-report-css' %}
+{% asset 'ckanext-validation/module-validation-report' %}
+{% asset 'ckanext-validation/validation-report-form-css' %}
+{% asset 'ckanext-validation/module-modal-dialog' %}
diff --git a/ckanext/validation/templates/validation/snippets/validation_report_dialog_bs2.html b/ckanext/validation/templates/validation/snippets/validation_report_dialog_bs2.html
index 5a980fab..17d9cf73 100644
--- a/ckanext/validation/templates/validation/snippets/validation_report_dialog_bs2.html
+++ b/ckanext/validation/templates/validation/snippets/validation_report_dialog_bs2.html
@@ -7,7 +7,8 @@
{{ _('Data Validation Report') }}
-
-{% set type = 'asset' %}
-{% include 'validation/snippets/validation_report_form_' ~ type ~ '.html' %}
-
+{% asset 'ckanext-validation/goodtables-ui' %}
+{% asset 'ckanext-validation/validation-report-css' %}
+{% asset 'ckanext-validation/module-validation-report' %}
+{% asset 'ckanext-validation/validation-report-form-css' %}
+{% asset 'ckanext-validation/module-modal-dialog' %}
diff --git a/ckanext/validation/templates/validation/snippets/validation_report_form_asset.html b/ckanext/validation/templates/validation/snippets/validation_report_form_asset.html
deleted file mode 100644
index de400faf..00000000
--- a/ckanext/validation/templates/validation/snippets/validation_report_form_asset.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{% asset 'ckanext-validation/goodtables-ui' %}
-{% asset 'ckanext-validation/validation-report-css' %}
-{% asset 'ckanext-validation/validation-report-form-css' %}
-{% asset 'ckanext-validation/module-validation-report' %}
-{% asset 'ckanext-validation/module-modal-dialog' %}
\ No newline at end of file
diff --git a/ckanext/validation/templates/validation/snippets/validation_resource-schema-form_asset.html b/ckanext/validation/templates/validation/snippets/validation_resource-schema-form_asset.html
deleted file mode 100644
index 62bb7b47..00000000
--- a/ckanext/validation/templates/validation/snippets/validation_resource-schema-form_asset.html
+++ /dev/null
@@ -1 +0,0 @@
-{% asset 'ckanext-validation/resource-schema-form' %}
\ No newline at end of file
diff --git a/ckanext/validation/templates/validation/snippets/validation_style_asset.html b/ckanext/validation/templates/validation/snippets/validation_style_asset.html
deleted file mode 100644
index d871253b..00000000
--- a/ckanext/validation/templates/validation/snippets/validation_style_asset.html
+++ /dev/null
@@ -1 +0,0 @@
-{% asset 'ckanext-validation/main-css' %}
\ No newline at end of file
diff --git a/ckanext/validation/templates/validation/validation_read.html b/ckanext/validation/templates/validation/validation_read.html
index d841e096..a27ce8bd 100644
--- a/ckanext/validation/templates/validation/validation_read.html
+++ b/ckanext/validation/templates/validation/validation_read.html
@@ -1,9 +1,7 @@
-{% set type = 'asset' %}
-
-{% include 'validation/snippets/validation_style_' ~ type ~ '.html' %}
-
{% extends "package/base.html" %}
+{% asset 'ckanext-validation/main-css' %}
+
{%- block subtitle %}{{ _('Validation Report') }}{% endblock -%}
{% block breadcrumb_content_selected %}{% endblock %}
@@ -40,9 +38,9 @@
{{ h.resource_display_name(resource) | truncate(50) }}
-
- {% include 'validation/snippets/validation_report_' ~ type ~ '.html' %}
-
+ {% asset 'ckanext-validation/goodtables-ui' %}
+ {% asset 'ckanext-validation/validation-report-css' %}
+ {% asset 'ckanext-validation/module-validation-report' %}
{% endblock %}
diff --git a/ckanext/validation/tests/test_logic.py b/ckanext/validation/tests/test_logic.py
index d5946d27..1688c39d 100644
--- a/ckanext/validation/tests/test_logic.py
+++ b/ckanext/validation/tests/test_logic.py
@@ -495,10 +495,10 @@ def test_package_patch_with_resources_does_not_set_context_flag(self):
@pytest.mark.usefixtures("clean_db", "validation_setup")
class TestAuth(object):
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_run_anon(self):
-
resource = factories.Resource()
-
context = {'user': None, 'model': model}
with pytest.raises(tk.NotAuthorized):
@@ -506,22 +506,24 @@ def test_run_anon(self):
context=context,
resource_id=resource['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_run_sysadmin(self):
resource = factories.Resource()
sysadmin = factories.Sysadmin()
-
context = {'user': sysadmin['name'], 'model': model}
assert call_auth('resource_validation_run',
context=context,
resource_id=resource['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_run_non_auth_user(self):
user = factories.User()
org = factories.Organization()
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()])
-
context = {'user': user['name'], 'model': model}
with pytest.raises(tk.NotAuthorized):
@@ -529,6 +531,8 @@ def test_run_non_auth_user(self):
context=context,
resource_id=dataset['resources'][0]['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_run_auth_user(self):
user = factories.User()
org = factories.Organization(users=[{
@@ -537,16 +541,16 @@ def test_run_auth_user(self):
}])
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()])
-
context = {'user': user['name'], 'model': model}
assert call_auth('resource_validation_run',
context=context,
resource_id=dataset['resources'][0]['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_delete_anon(self):
resource = factories.Resource()
-
context = {'user': None, 'model': model}
with pytest.raises(tk.NotAuthorized):
@@ -554,22 +558,24 @@ def test_delete_anon(self):
context=context,
resource_id=resource['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_delete_sysadmin(self):
resource = factories.Resource()
sysadmin = factories.Sysadmin()
-
context = {'user': sysadmin['name'], 'model': model}
assert call_auth('resource_validation_delete',
context=context,
resource_id=resource['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_delete_non_auth_user(self):
user = factories.User()
org = factories.Organization()
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()])
-
context = {'user': user['name'], 'model': model}
with pytest.raises(tk.NotAuthorized):
@@ -577,6 +583,8 @@ def test_delete_non_auth_user(self):
context=context,
resource_id=dataset['resources'][0]['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_delete_auth_user(self):
user = factories.User()
org = factories.Organization(users=[{
@@ -585,42 +593,44 @@ def test_delete_auth_user(self):
}])
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()])
-
context = {'user': user['name'], 'model': model}
assert call_auth('resource_validation_delete',
context=context,
resource_id=dataset['resources'][0]['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_show_anon(self):
resource = factories.Resource()
-
context = {'user': None, 'model': model}
assert call_auth('resource_validation_show',
context=context,
resource_id=resource['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_show_anon_public_dataset(self):
user = factories.User()
org = factories.Organization()
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()],
private=False)
-
context = {'user': user['name'], 'model': model}
assert call_auth('resource_validation_show',
context=context,
resource_id=dataset['resources'][0]['id'])
+ @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", False)
+ @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False)
def test_show_anon_private_dataset(self):
user = factories.User()
org = factories.Organization()
dataset = factories.Dataset(owner_org=org['id'],
resources=[factories.Resource()],
private=True)
-
context = {'user': user['name'], 'model': model}
with pytest.raises(tk.NotAuthorized):
diff --git a/test/features/environment.py b/test/features/environment.py
index 09c59658..73e588b3 100644
--- a/test/features/environment.py
+++ b/test/features/environment.py
@@ -14,7 +14,7 @@
# URL of remote Chrome instance.
REMOTE_CHROME_URL = 'http://chrome:4444/wd/hub'
-# @see .docker/scripts/init.sh for credentials.
+# @see bin/init.sh for credentials.
PERSONAS = {
'SysAdmin': {
'name': u'admin',
diff --git a/test/features/resource_validation.feature b/test/features/resource_validation.feature
index 02bd342e..010b3b3e 100644
--- a/test/features/resource_validation.feature
+++ b/test/features/resource_validation.feature
@@ -4,8 +4,8 @@ Feature: Resource validation
Given "TestOrgEditor" as the persona
When I log in
And I open the new resource form for dataset "warandpeace"
- And I fill in "name" with "Test validation schema"
And I attach the file "test.csv" to "upload"
+ And I fill in "name" with "Test validation schema"
And I fill in "description" with "Testing validation schema"
And I attach the file "test_schema.json" to "schema_upload"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
@@ -35,8 +35,8 @@ Feature: Resource validation
Given "TestOrgEditor" as the persona
When I log in
And I open the new resource form for dataset "warandpeace"
- And I fill in "name" with "Test validation options"
And I attach the file "test.csv" to "upload"
+ And I fill in "name" with "Test validation options"
And I fill in "description" with "Testing validation options"
And I attach the file "test_schema.json" to "schema_upload"
And I fill in "validation_options" with "{"headers": 1}"
@@ -63,8 +63,8 @@ Feature: Resource validation
Given "TestOrgEditor" as the persona
When I log in
And I open the new resource form for dataset "warandpeace"
- And I fill in "name" with "Test valid CSV create"
And I attach the file "test.csv" to "upload"
+ And I fill in "name" with "Test valid CSV create"
And I attach the file "test_schema.json" to "schema_upload"
And I fill in "description" with "Testing validation that should pass"
And I execute the script "document.getElementById('field-format').value='CSV'"
@@ -80,8 +80,8 @@ Feature: Resource validation
Given "TestOrgEditor" as the persona
When I log in
And I open the new resource form for dataset "warandpeace"
- And I fill in "name" with "Test valid CSV update"
And I attach the file "invalid.csv" to "upload"
+ And I fill in "name" with "Test valid CSV update"
And I fill in "description" with "Testing validation that should pass on update"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
Then I should see "Test valid CSV update"
@@ -101,8 +101,8 @@ Feature: Resource validation
Given "TestOrgEditor" as the persona
When I log in
And I open the new resource form for dataset "warandpeace"
- And I fill in "name" with "Test invalid CSV update"
And I attach the file "test.csv" to "upload"
+ And I fill in "name" with "Test invalid CSV update"
And I attach the file "test_schema.json" to "schema_upload"
And I fill in "description" with "Testing validation that should fail on update"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py
index c789500f..9950d0c6 100644
--- a/test/features/steps/steps.py
+++ b/test/features/steps/steps.py
@@ -53,8 +53,7 @@ def attempt_login(context, password):
@step(u'I open the new resource form for dataset "{name}"')
def go_to_new_resource_form(context, name):
context.execute_steps(u"""
- When I go to dataset "{name}"
- And I click the link with text that contains "Manage"
+ When I edit the "{name}" dataset
And I click the link with text that contains "Resources"
And I click the link with text that contains "Add new resource"
""".format(name=name))
@@ -65,11 +64,12 @@ def add_resource(context, name, url):
context.execute_steps(u"""
When I log in
And I open the new resource form for dataset "warandpeace"
- And I press the element with xpath "//form[@id='resource-edit']//a[string() = 'Link']"
- And I fill in "name" with "{}"
- And I fill in "url" with "{}"
- And I press the element with xpath "//button[contains(string(), 'Add')]"
- """.format(name, url))
+ And I execute the script "$('#resource-edit [name=url]').val('{url}')"
+ And I fill in "name" with "{name}"
+ And I fill in "description" with "description"
+ And I execute the script "document.getElementById('field-format').value='HTML'"
+ And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]"
+ """.format(name=name, url=url))
@step(u'I go to dataset page')
@@ -82,6 +82,14 @@ def go_to_dataset(context, name):
when_i_visit_url(context, '/dataset/' + name)
+@step(u'I edit the "{name}" dataset')
+def edit_dataset(context, name):
+ context.execute_steps(u"""
+ When I go to dataset "{name}"
+ And I click the link with text that contains "Manage"
+ """.format(name=name))
+
+
@step(u'I go to organisation page')
def go_to_organisation_page(context):
when_i_visit_url(context, '/organization')
@@ -109,7 +117,16 @@ def go_to_user_profile(context, user_id):
@step(u'I go to the dashboard')
def go_to_dashboard(context):
- when_i_visit_url(context, '/dashboard')
+ context.execute_steps(u"""
+ When I visit "/dashboard/datasets"
+ """)
+
+
+@step(u'I should see my datasets')
+def dashboard_datasets(context):
+ context.execute_steps(u"""
+ Then I should see an element with xpath "//li[contains(@class, 'active') and contains(string(), 'My Datasets')]"
+ """)
@step(u'I go to the "{user_id}" user API')
@@ -119,12 +136,19 @@ def go_to_user_show(context, user_id):
@step(u'I view the "{group_id}" group API "{including}" users')
def go_to_group_including_users(context, group_id, including):
- when_i_visit_url(context, r'/api/3/action/group_show?id={}&include_users={}'.format(group_id, including in ['with', 'including']))
+ when_i_visit_url(
+ context, r'/api/3/action/group_show?id={}&include_users={}'.format(
+ group_id, including in ['with', 'including']))
@step(u'I view the "{organisation_id}" organisation API "{including}" users')
def go_to_organisation_including_users(context, organisation_id, including):
- when_i_visit_url(context, r'/api/3/action/organization_show?id={}&include_users={}'.format(organisation_id, including in ['with', 'including']))
+ when_i_visit_url(
+ context, r'/api/3/action/organization_show?id={}&include_users={}'.format(
+ organisation_id, including in ['with', 'including']))
+
+
+# ckanext-validation
@step(u'I should see a validation timestamp')