Skip to content

Commit

Permalink
Merge pull request #270 from qld-gov-au/QOLDEV-1070-ckan-2.11
Browse files Browse the repository at this point in the history
[QOLDEV-1070] add more scenario tests
  • Loading branch information
ThrawnCA authored Feb 19, 2025
2 parents dab2a1d + 7bb59f2 commit b841b6d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ commands:
usage: Run unit tests.
cmd: |
ahoy title 'Run unit tests'
ahoy cli 'pytest -vvv --ckan-ini=.docker/test.ini "${APP_DIR}"/ckanext/data_qld/tests/test_api.py --junit-xml=test/junit/results.xml' || \
ahoy cli 'pytest --ckan-ini=.docker/test.ini "${APP_DIR}"/ckanext --junit-xml=test/junit/results.xml' || \
[ "${ALLOW_UNIT_FAIL:-0}" -eq 1 ]
test-unit-failed-rerun:
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
include LICENSE
include requirements.txt
recursive-include ckanext/data-qld *.html *.json *.js *.less *.css *.mo
recursive-include ckanext *.html *.json *.js *.less *.css *.mo
4 changes: 2 additions & 2 deletions ckanext/data_qld/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_get_create_mode_if_no_schema_and_de_identified(
"""Validation must be in async mode if we don't have a schema and dataset
is de_identified"""
dataset = dataset_factory(de_identified_data="YES")
resource = resource_factory(package_id=dataset["id"])
resource = resource_factory(package_id=dataset["id"], schema=None)

mode = validation_settings.get_create_mode({}, resource)
assert mode == validation_settings.ASYNC_MODE
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_get_update_mode_if_no_schema_and_de_identified(
"""Validation must be in async mode if we don't have a schema and dataset
is de_identified"""
dataset = dataset_factory(de_identified_data="YES")
resource = resource_factory(package_id=dataset["id"])
resource = resource_factory(package_id=dataset["id"], schema=None)

mode = validation_settings.get_update_mode({}, resource)
assert mode == validation_settings.ASYNC_MODE
Expand Down
16 changes: 16 additions & 0 deletions test/features/resource_type_validation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@resource_type_validation
Feature: Resource type validation

Scenario: As an evil user, when I try to upload a resource with a MIME type not matching its extension, I should get an error
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset with key-value parameters "notes=Testing resource type mismatch"
And I open the new resource form for dataset "$last_generated_name"
And I create a resource with key-value parameters "name=Testing EICAR PDF::description=Testing EICAR sample virus file with PDF extension::format=PDF::upload=eicar.com.pdf"
Then I should see "Mismatched file type"

Scenario: As a publisher, when I create a resource linking to an internal URL, I should not see any type mismatch errors
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "notes=Testing internal URL" and "name=Internal link::url=http://ckan:5000/api/action/status_show"
Then I should see "Testing internal URL"
2 changes: 1 addition & 1 deletion test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def _parse_params(param_string):
for param in param_string.split("::"):
entry = param.split("=", 1)
params[entry[0]] = entry[1] if len(entry) > 1 else ""
return params.items()
return six.iteritems(params)


@when(u'I show the non-JavaScript schema fields')
Expand Down
36 changes: 36 additions & 0 deletions test/features/xloader.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@OpenData
@XLoader
Feature: XLoader

Scenario: As a publisher, when I visit a resource I control with a datastore entry, I can access the XLoader interface
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "notes=Testing XLoader" and "name=test-csv-resource::url=https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv::format=CSV"
# Wait for XLoader to run
And I press "test-csv-resource"
And I reload page every 3 seconds until I see an element with xpath "//*[contains(string(), 'DataStore')]" but not more than 6 times
Then I should see "DataStore"

When I press "DataStore"
And I reload page every 3 seconds until I see an element with xpath "//*[contains(string(), 'Express Load completed')]" but not more than 6 times
Then I should see "Express Load completed"
And I should see "Data Schema"
And I should see "Data Dictionary"
And I should see "Upload to DataStore"
And I should see "Delete from DataStore"
And I should see "Status"
And I should see "Last updated"
And I should see "Upload Log"
And I should see "View resource"

When I press "Upload to DataStore"
Then I should see "Status"
And I should see "Pending"
And I should see "Delete from DataStore"

When I press "Delete from DataStore"
And I confirm the dialog containing "delete the DataStore" if present
Then I should see "DataStore and Data Dictionary deleted for resource"
And I should see "Upload to DataStore"
And I should not see "Delete from DataStore"
And I should not see an element with xpath "//a[contains(@href, '/dictionary/')]"
Binary file added test/fixtures/eicar.com.pdf
Binary file not shown.

0 comments on commit b841b6d

Please sign in to comment.