Skip to content

Commit

Permalink
Merge pull request #251 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master - fix integration with QA plugin
  • Loading branch information
ThrawnCA authored Jul 18, 2024
2 parents b8f2df2 + c3c0801 commit 8756881
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install requirements
Expand All @@ -37,7 +37,7 @@ jobs:
BEHAVE_TAG: ${{ matrix.behave-tag }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
timeout-minutes: 2

- name: Build
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: CKAN ${{ matrix.ckan-version }} ${{ matrix.behave-tag }} screenshots
path: /tmp/artifacts/behave/screenshots
Expand Down
7 changes: 5 additions & 2 deletions ckanext/data_qld/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
from .resource_freshness import validation as resource_freshness_validator
from .resource_freshness.logic.actions import get as resource_freshness_get_actions

if ' qa' in tk.config.get('ckan.plugins', ''):
try:
from ckanext.qa.interfaces import IQA
import ckanext.qa.lib as qa_lib
import ckanext.qa.tasks as qa_tasks
import os
qa_present = True
except ImportError:
qa_present = False


log = logging.getLogger(__name__)
Expand All @@ -43,7 +46,7 @@ class DataQldPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IBlueprint)
plugins.implements(plugins.IClick)

if ' qa' in tk.config.get('ckan.plugins', ''):
if qa_present:
plugins.implements(IQA)

# IConfigurer
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ xlrd==1.2.0
python-magic==0.4.18
progressbar==2.5

typer<0.11 # We still need Click 7 for now
pika>=1.1.0,<1.3.0 # resolve harvester conflict
11 changes: 11 additions & 0 deletions test/features/data_usability_rating.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ Feature: Data usability rating
| CSV | csv_resource.csv | 3 |
| JSON | json_resource.json | 3 |
| RDF | rdf_resource.rdf | 4 |

Scenario: As a publisher, when I create an open resource with a matching schema, I can verify the score is upgraded from 3 to 4
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "license=other-open" and "format=CSV::upload=test_game_data.csv::schema=default"
And I press the element with xpath "//ol[contains(@class, 'breadcrumb')]//a[starts-with(@href, '/dataset/')]"
And I reload page every 3 seconds until I see an element with xpath "//div[contains(@class, 'qa') and contains(@class, 'openness-')]" but not more than 10 times
Then I should not see an element with xpath "//div[contains(@class, 'openness-3')]"
And I should see an element with xpath "//div[contains(@class, 'openness-4')]"
When I press "Test Resource"
Then I should see an element with xpath "//div[contains(@class, 'qa openness-4')]"
16 changes: 15 additions & 1 deletion test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,22 @@ def fill_in_default_link_resource_fields(context):
@when(u'I upload "{file_name}" of type "{file_format}" to resource')
def upload_file_to_resource(context, file_name, file_format):
context.execute_steps(u"""
When I execute the script "$('#resource-upload-button').trigger(click);"
When I execute the script "$('#resource-upload-button').trigger('click');"
And I attach the file "{file_name}" to "upload"
# Don't quote the injected string since it can have trailing spaces
And I execute the script "document.getElementById('field-format').value='{file_format}'"
And I fill in "size" with "1024" if present
""".format(file_name=file_name, file_format=file_format))


@when(u'I upload schema file "{file_name}" to resource')
def upload_schema_file_to_resource(context, file_name):
context.execute_steps(u"""
When I execute the script "$('#field-schema-json ~ a.btn-remove-url').trigger('click');"
And I attach the file "{file_name}" to "schema_upload"
""".format(file_name=file_name))


@when(u'I go to group page')
def go_to_group_page(context):
context.execute_steps(u"""
Expand Down Expand Up @@ -527,6 +535,12 @@ def create_resource_from_params(context, resource_params):
if value == "default":
value = resource_default_schema
_enter_manual_schema(context, value)
elif key == "schema_upload":
if value == "default":
value = "test-resource_schemea.json"
context.execute_steps(u"""
When I upload schema file "{0}" to resource
""".format(value))
else:
context.execute_steps(u"""
When I fill in "{0}" with "{1}" if present
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/csv_resource_with_schema.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,location,date,measurement,observations
1,A,01/01/1970,12345,"Lorem ipsum"

0 comments on commit 8756881

Please sign in to comment.