- {% endblock %} {% block flash %} {% set flash_messages = h.flash.pop_messages() | list %} {% if flash_messages %} + {% endblock %} {% block flash %} {% set flash_messages = h.get_flashed_messages() | list %} {% if flash_messages %}
- {% for message in flash_messages %} -
{{ h.literal(message) }}
+ {% for category, message in h.get_flashed_messages(with_categories=true) %} +
{{ h.literal(message) }}
{% endfor %}
{% endif %} {% endblock %} {% block footer %} {% include "footer.html" %} {% include "snippets/identifier.html" %} {% diff --git a/ckanext/datagovtheme/templates/snippets/home_breadcrumb_item.html b/ckanext/datagovtheme/templates/snippets/home_breadcrumb_item.html index 259c9496..e0307b3d 100644 --- a/ckanext/datagovtheme/templates/snippets/home_breadcrumb_item.html +++ b/ckanext/datagovtheme/templates/snippets/home_breadcrumb_item.html @@ -1,2 +1,2 @@ {# Used to insert the home icon into a breadcrumb #} -
  • {{ _('Home') }}
  • +
  • {{ _('Home') }}
  • diff --git a/ckanext/datagovtheme/templates/snippets/search_form.html b/ckanext/datagovtheme/templates/snippets/search_form.html new file mode 100644 index 00000000..0f0d47e5 --- /dev/null +++ b/ckanext/datagovtheme/templates/snippets/search_form.html @@ -0,0 +1,20 @@ +{% ckan_extends %} + +{% block search_sortby %} + {% if sorting %} +
    + +
    + + {% block search_sortby_button %} + + {% endblock %} +
    + {% endif %} +{% endblock %} diff --git a/ckanext/datagovtheme/templates/snippets/sort_by.html b/ckanext/datagovtheme/templates/snippets/sort_by.html index 96884655..1d7e22ae 100644 --- a/ckanext/datagovtheme/templates/snippets/sort_by.html +++ b/ckanext/datagovtheme/templates/snippets/sort_by.html @@ -8,15 +8,15 @@ {% snippet 'snippets/sort_by.html', sort=c.sort_by_selected %} #} - +
    - - + - - + +
    diff --git a/ckanext/datagovtheme/tests/test_datagovtheme.py b/ckanext/datagovtheme/tests/test_datagovtheme.py index 9ad3a60f..efbf1f1a 100644 --- a/ckanext/datagovtheme/tests/test_datagovtheme.py +++ b/ckanext/datagovtheme/tests/test_datagovtheme.py @@ -6,6 +6,7 @@ import ckanext.harvest.model as harvest_model from ckan.tests import factories from ckan.tests.helpers import reset_db +from ckan.lib.helpers import url_for from ckan.lib.search import rebuild import pytest import re @@ -13,7 +14,7 @@ # The /dataset page uses get_pkg_dict_extra which depends on HarvestObject, # hence the harvest extension. Include it for these tests. -@pytest.mark.ckan_config('ckan.plugins', 'harvest datagovtheme') +@pytest.mark.ckan_config('ckan.plugins', 'harvest geodatagov datagovtheme') @pytest.mark.use_fixtures('with_plugins', 'clean_db') class TestDatagovthemeServed(object): '''Tests for the ckanext.datagovtheme.plugin module.''' @@ -45,7 +46,8 @@ def get_base_dataset(self): def create_datasets(self, dataset): d1 = dataset.copy() d1.update({'title': 'test 01 dataset', 'unique_id': 't1'}) - factories.Dataset(**d1) + new_dataset = factories.Dataset(**d1) + return new_dataset['id'] def test_homepage_redirect(self, app): index_response = app.get('/') @@ -102,8 +104,8 @@ def test_datagovtheme_bureau_names(self, app): def test_datagovtheme_package_metadata(self, app): dataset = self.get_base_dataset() dataset['extras'].append({'key': 'contact-email', 'value': 'test@email.com'}) - self.create_datasets(dataset) + dataset_id = self.create_datasets(dataset) - index_response = app.get('/dataset/test_dataset_02') + index_response = app.get(url_for("dataset.read", id=dataset_id), status=200) assert 'test@email.com' in index_response.body diff --git a/ckanext/datagovtheme/tests/test_notes.py b/ckanext/datagovtheme/tests/test_notes.py index 2d77bebb..3b4d6d81 100644 --- a/ckanext/datagovtheme/tests/test_notes.py +++ b/ckanext/datagovtheme/tests/test_notes.py @@ -7,7 +7,7 @@ # The /dataset page uses get_pkg_dict_extra which depends on HarvestObject, # hence the harvest extension. Include it for these tests. -@pytest.mark.ckan_config('ckan.plugins', 'harvest datagovtheme') +@pytest.mark.ckan_config('ckan.plugins', 'harvest geodatagov datagovtheme') @pytest.mark.use_fixtures('with_plugins', 'clean_db', 'clean_index') class TestNotes(object): '''Tests for the ckanext.datagovtheme.plugin module.''' diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 00000000..9e969975 --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,21 @@ +const { defineConfig } = require("cypress"); + +module.exports = defineConfig({ + videoCompression: false, + videoUploadOnPasses: false, + screenshotOnRunFailure: false, + e2e: { + baseUrl: "http://localhost:5000", + }, + + env: { + USER: "admin", + USER_PASSWORD: "password", + }, + + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + }, +}); diff --git a/cypress/e2e/contact.cy.js b/cypress/e2e/contact.cy.js new file mode 100644 index 00000000..20c5b979 --- /dev/null +++ b/cypress/e2e/contact.cy.js @@ -0,0 +1,10 @@ +describe('Dataset page contact', () => { + // Uses datasets from seed.py which created test ones to check + + it('check contact email', () => { + cy.visit('/dataset'); + cy.get('#search-big').type('test 01 dataset{enter}'); + cy.get('ul.dataset-list > li:first a').click({force: true}); + cy.get('.additional-info').contains('test@email.com'); + }); +}); diff --git a/e2e/cypress/integration/facets_bureaus_name.spec.js b/cypress/e2e/facets_bureaus_name.cy.js similarity index 100% rename from e2e/cypress/integration/facets_bureaus_name.spec.js rename to cypress/e2e/facets_bureaus_name.cy.js diff --git a/e2e/cypress/integration/unique_identifier.spec.js b/cypress/e2e/unique_identifier.cy.js similarity index 61% rename from e2e/cypress/integration/unique_identifier.spec.js rename to cypress/e2e/unique_identifier.cy.js index 504eb32f..4fed7e17 100644 --- a/e2e/cypress/integration/unique_identifier.spec.js +++ b/cypress/e2e/unique_identifier.cy.js @@ -2,8 +2,9 @@ describe('Dataset page identifier', () => { // Uses datasets from seed.py which created test ones to check it('check unique identifier is not unknow', () => { - cy.visit('/dataset/test_dataset_04'); - cy.get('th[property="rdfs:label"]').contains('Unique Identifier') + cy.visit('/dataset'); + cy.get('ul.dataset-list > li:first a').click({force: true}); + cy.get('th[property="rdfs:label"]').contains('Identifier') .get('td[property="rdf:value"]').should('not.have.text', 'Unknown'); }); }); diff --git a/e2e/cypress/fixtures/ckan_dataset.json b/cypress/fixtures/ckan_dataset.json similarity index 100% rename from e2e/cypress/fixtures/ckan_dataset.json rename to cypress/fixtures/ckan_dataset.json diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 00000000..fd100335 --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,32 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add('login', (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +Cypress.Commands.add('hide_debug_toolbar', () => { + cy.get('#flDebugHideToolBarButton').then(($button) => { + if ($button.is(':visible')) { + cy.get('#flDebugHideToolBarButton').click(); + } + }); +}); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js new file mode 100644 index 00000000..d68db96d --- /dev/null +++ b/cypress/support/e2e.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/docker-compose.test.yml b/docker-compose.test.yml index c6efd7cb..b59c6bc5 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -2,7 +2,7 @@ version: '3' services: test: - image: cypress/included:7.3.0 + image: cypress/included:12.10.0 entrypoint: [] command: /bin/bash -c "npx wait-on http://ckan:5000/dataset && cypress run" # To run specific test, use the following syntax: @@ -11,8 +11,9 @@ services: # Created cypress user and password, setup in 00-setup-cypress-user.sh - CYPRESS_USER=admin - CYPRESS_USER_PASSWORD=password + - CYPRESS_BASE_URL=http://ckan:5000 working_dir: /e2e depends_on: - ckan volumes: - - ./e2e:/e2e + - ${PWD}:/e2e diff --git a/docker-compose.yml b/docker-compose.yml index 2f3ba8ce..3d7ba858 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: CKAN_SYSADMIN_PASSWORD: password CKAN_SYSADMIN_EMAIL: your_email@example.com CKAN__STORAGE_PATH: /var/lib/ckan - CKAN__PLUGINS: harvest datagovtheme + CKAN__PLUGINS: harvest geodatagov datagovtheme PYTHONDONTWRITEBYTECODE: 1 ports: - "5000:5000" @@ -36,7 +36,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./docker-entrypoint.d/:/docker-entrypoint.d/ db: - image: ckan/ckan-postgres-dev:${CKAN_VERSION} + image: ckan/ckan-postgres-dev:2.10 environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -49,4 +49,4 @@ services: redis: image: redis solr: - image: ckan/ckan-solr-dev:${CKAN_VERSION} + image: ckan/ckan-solr-dev:2.9 diff --git a/docker-entrypoint.d/seed.py b/docker-entrypoint.d/seed.py index 133214de..234ebdc5 100644 --- a/docker-entrypoint.d/seed.py +++ b/docker-entrypoint.d/seed.py @@ -40,7 +40,7 @@ def get_base_dataset(): # Without the request context, db operations won't work with test_app.flask_app.test_request_context(): try: - user = factories.Sysadmin(name='asdfs') + user = factories.Sysadmin() user_name = user['name'].encode('ascii') print('User created') except sqlalchemy.exc.IntegrityError: @@ -57,7 +57,7 @@ def get_base_dataset(): for x in range(1, 6): try: dataset = get_base_dataset() - dataset['extras'].append({'key': 'unique identifier', 'value': f'id-{x}'}) + dataset['extras'].append({'key': 'identifier', 'value': f'id-{x}'}) dataset.update({'title': f"test 0{x} dataset", 'id': f't{x}'}) factories.Dataset(**dataset) print(f'Dataset {x} created') diff --git a/e2e/cypress.json b/e2e/cypress.json deleted file mode 100644 index 000ec710..00000000 --- a/e2e/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "baseUrl": "http://ckan:5000", - "videoCompression": false, - "videoUploadOnPasses": false, - "screenshotOnRunFailure": false, - "env": { - "USER": "admin", - "USER_PASSWORD": "password" - } -} \ No newline at end of file diff --git a/e2e/cypress/integration/contact.spec.js b/e2e/cypress/integration/contact.spec.js deleted file mode 100644 index a22d3a3e..00000000 --- a/e2e/cypress/integration/contact.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -describe('Dataset page contact', () => { - // Uses datasets from seed.py which created test ones to check - - it('check contact email', () => { - cy.visit('/dataset/test_dataset_04'); - cy.get('section[class="module module-narrow contact"] p[class="module-content"]').should('not.have.text', 'Unknown'); - }); -}); diff --git a/e2e/cypress/plugins/index.js b/e2e/cypress/plugins/index.js deleted file mode 100644 index 59b2bab6..00000000 --- a/e2e/cypress/plugins/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} diff --git a/requirements.txt b/requirements.txt index c14d8586..bac362da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,16 @@ # ckanext-harvest -e git+https://github.com/ckan/ckanext-harvest.git@master#egg=ckanext_harvest --e git+https://github.com/gsa/ckanext-spatial.git@datagov#egg=ckanext-spatial +-e git+https://github.com/ckan/ckanext-spatial.git@master#egg=ckanext-spatial +-e git+https://github.com/gsa/ckanext-geodatagov.git@main#egg=ckanext-geodatagov # ckanext-harvest dependencies ckantoolkit>=0.0.7 pika>=1.1.0 -pyOpenSSL==20.0.1 +pyOpenSSL>22.10 # redis==2.10.6 # included in ckan core # requests>=2.11.1 # included in ckan core + +boto3 +geojson==3.0.1 +owslib +-e git+https://github.com/asl2/PyZ3950.git#egg=PyZ3950 diff --git a/setup.py b/setup.py index 8cf51db8..4bbe7a81 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='ckanext-datagovtheme', - version='0.1.27', + version='0.2.1', description="CKAN Extension to manage data.gov theme", long_description=long_description, classifiers=[