Skip to content

Commit

Permalink
Merge pull request #108 from qld-gov-au/QOLDEV-982-ckan-2.11
Browse files Browse the repository at this point in the history
[QOLDEV-982] sync test config with other repos
  • Loading branch information
ThrawnCA authored Feb 24, 2025
2 parents 8f70736 + c841756 commit 1820e93
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 42 deletions.
7 changes: 1 addition & 6 deletions .docker/Dockerfile-template.ckan
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ RUN ORIGINAL_USER=$(id -un)
ARG SITE_URL=http://ckan:5000/
ENV PYTHON_VERSION={PYTHON_VERSION}
ENV CKAN_VERSION={CKAN_VERSION}
ENV SOLR_VERSION={SOLR_VERSION}
ENV CKAN_SITE_URL="${SITE_URL}"
ENV PYTHON={PYTHON}

Expand All @@ -24,11 +23,7 @@ COPY bin/ckan_cli /usr/bin/
RUN chmod +x "${APP_DIR}"/bin/*.sh /usr/bin/ckan_cli

RUN which ps || apt-get install -y procps

# Install setuptools conditionally
RUN if [ "$CKAN_VERSION" = "2.9" ]; then \
pip install "setuptools>=44.1.0,<71"; \
fi
RUN pip install uv

# Install CKAN.

Expand Down
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ALLOW_BDD_FAIL=0
# Disable amazeeio based health checks
DOCTOR_CHECK_WEBSERVER=0
DOCTOR_CHECK_BOOTSTRAP=0
DOCTOR_CHECK_PYGMY=0
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@ jobs:
strategy:
fail-fast: false
matrix:
ckan-version: ['2.10']
solr-version: ['8']
ckan-version: ['2.11', '2.10']
experimental: [false]
include:
- ckan-version: '2.11'
solr-version: '9'
experimental: false
- ckan-version: 'master'
solr-version: '9'
experimental: true #master is unstable, good to know if we are compatible or not

name: ${{ matrix.experimental && '**Fail_Ignored** ' || '' }} CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container: drevops/ci-runner:23.12.0
env:
CKAN_VERSION: ${{ matrix.ckan-version }}
SOLR_VERSION: ${{ matrix.solr-version }}

steps:
# Patch https://github.com/actions/runner/issues/863
Expand Down
7 changes: 5 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ PYTHON_VERSION=py3

CKAN_GIT_VERSION=$CKAN_VERSION
CKAN_GIT_ORG=qld-gov-au
SOLR_VERSION=9

if [ "$CKAN_VERSION" = "2.11" ]; then
CKAN_GIT_VERSION=ckan-2.11.1-qgov.2
CKAN_GIT_VERSION=ckan-2.11.2-qgov.1
elif [ "$CKAN_VERSION" = "2.10" ]; then
CKAN_GIT_VERSION=ckan-2.10.5-qgov.5
CKAN_GIT_VERSION=ckan-2.10.7-qgov.1
SOLR_VERSION=8
elif [ "$CKAN_VERSION" = "master" ]; then
CKAN_GIT_ORG=ckan
fi
Expand All @@ -35,4 +37,5 @@ sed "s|{CKAN_VERSION}|$CKAN_VERSION|g" .docker/Dockerfile-template.ckan \
| sed "s|{PYTHON}|$PYTHON|g" \
> .docker/Dockerfile.ckan

export SOLR_VERSION
ahoy build
19 changes: 12 additions & 7 deletions bin/init-ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
#
set -ex

install_requirements_file () {
if [ "$TOOL" = "uv" ]; then
uv pip install --system -r "$1"
else
pip install -r "$1"
fi
}

install_requirements () {
PROJECT_DIR=$1
shift
Expand All @@ -12,33 +20,30 @@ install_requirements () {
for filename_pattern in "$@"; do
filename="$PROJECT_DIR/${filename_pattern}-$CKAN_VERSION.txt"
if [ -f "$filename" ]; then
pip install -r "$filename"
install_requirements_file "$filename"
return 0
fi
done
for filename_pattern in "$@"; do
filename="$PROJECT_DIR/${filename_pattern}-$PYTHON_VERSION.txt"
if [ -f "$filename" ]; then
pip install -r "$filename"
install_requirements_file "$filename"
return 0
fi
done
for filename_pattern in "$@"; do
filename="$PROJECT_DIR/$filename_pattern.txt"
if [ -f "$filename" ]; then
pip install -r "$filename"
install_requirements_file "$filename"
return 0
fi
done
}

. "${APP_DIR}"/bin/activate
if [ "$CKAN_VERSION" = "2.9" ]; then
pip install "setuptools>=44.1.0,<71"
fi
install_requirements . dev-requirements requirements-dev
for extension in . `ls -d $SRC_DIR/ckanext-*`; do
install_requirements $extension requirements pip-requirements
TOOL=uv install_requirements $extension requirements pip-requirements
done
pip install -e .
installed_name=$(grep '^\s*name=' setup.py |sed "s|[^']*'\([-a-zA-Z0-9]*\)'.*|\1|")
Expand Down
1 change: 1 addition & 0 deletions bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ set -e
. "${APP_DIR}"/bin/activate
CLICK_ARGS="--yes" ckan_cli db clean
ckan_cli db init
ckan_cli db upgrade
40 changes: 20 additions & 20 deletions ckanext/publications_qld_theme/templates/package/group_list.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{% extends "package/read_base.html" %}
{% import 'macros/form.html' as form %}
{% ckan_extends %}

{# Replace 'group' with 'category' #}

{% set default_group_type = h.default_group_type('group') %}

{% block primary_content_inner %}
<h2 class="hide-heading">{{ _('Categories') }}</h2>
<h2 class="hide-heading">{{ h.humanize_entity_type('group', default_group_type, 'page title') or _('Categories') }}</h2>

{% if h.check_access('package_update', {'id':c.pkg_dict.id }) %}
{% set groups = h.groups_available() %}
{% if groups %}
<form class="add-to-group" method="post">
<div class="form-group">
<select id="field-add_group" class="form-control" name="group_added">
{% for option in groups %}
<option value="{{ option.id }}"> {{ option.display_name }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary" title="{{ _('Associate this category with this dataset') }}">{{ _('Add to category') }}</button>
</form>
{% endif %}
{% if group_dropdown %}
<form class="add-to-group" method="post">
{{ h.csrf_input() }}
<select id="field-add_group" name="group_added" data-module="autocomplete">
{% for option in group_dropdown %}
<option value="{{ option[0] }}"> {{ option[1] }}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary" title="{{ _('Associate this category with this dataset') }}">{{ _('Add to category') }}</button>
</form>
{% endif %}

{% if c.pkg_dict.groups %}
{% if pkg_dict.groups %}
<form method="post">
{% snippet 'group/snippets/group_list.html', groups=c.pkg_dict.groups %}
{{ h.csrf_input() }}
{% snippet 'group/snippets/group_list.html', groups=pkg_dict.groups %}
</form>
{% else %}
<p class="empty">{{ _('There are no categories associated with this dataset') }}</p>
<p class="empty">{{ h.humanize_entity_type('group', default_group_type, 'no associated label') or _('There are no categories associated with this dataset') }}</p>
{% endif %}

{% endblock %}
29 changes: 29 additions & 0 deletions test/features/groups.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,32 @@ Feature: Group APIs

When I view the "silly-walks" group API "not including" users
Then I should see an element with xpath "//*[contains(string(), '"success": true') and contains(string(), '"name": "silly-walks"')]"

Scenario: As a sysadmin, when I create a group with a long name, it should be preserved
Given "SysAdmin" as the persona
When I log in
And I go to group page
And I click the link to "/group/new"
And I fill in title with random text starting with "Group name more than 35 characters"
And I set "group_title" to "$last_generated_title"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
And I take a debugging screenshot
# Breadcrumb should be truncated but preserve full name in a tooltip
Then I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"

# Search facets should be truncated but preserve full name in a tooltip
When I create a dataset and resource with key-value parameters "notes=Testing long group name" and "name=Test"
And I press "Groups"
When I select by text " $group_title" from "group_added"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
Then I should see an element with xpath "//form//a[normalize-space() = '$group_title']"
When I press "$group_title"

Then I should see a search facet for "$group_title" truncated to "Group name more"
When I press the search facet pointing to "$group_title"
Then I should see an active search facet for "$group_title" truncated to "Group name more"

When I go to dataset page
Then I should see a search facet for "$group_title" truncated to "Group name more"
When I press the search facet pointing to "$group_title"
Then I should see an active search facet for "$group_title" truncated to "Group name more"
21 changes: 21 additions & 0 deletions test/features/organisations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,24 @@ Feature: Organization APIs
Then I should see "Test Organisation"
And I should see an element with xpath "//a[contains(@href, 'organization/new') and contains(string(), 'Add Organisation')]"

Scenario: As a sysadmin, when I create an organisation with a long name, it should be preserved
Given "SysAdmin" as the persona
When I log in
And I go to organisation page
And I click the link to "/organization/new"
And I fill in title with random text starting with "Org name more than 35 characters"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
And I take a debugging screenshot
# Breadcrumb should be truncated but preserve full name in a tooltip
Then I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]"

# Search facets should be truncated but preserve full name in a tooltip
When I create a dataset and resource with key-value parameters "notes=Testing long org name::owner_org=Org name more than" and "name=Test"
And I press "Org name more than"
Then I should see a search facet for "Org name more than 35 characters" truncated to "Org name more than"
When I press the search facet pointing to "Org name more than 35 characters"
Then I should see an active search facet for "Org name more than 35 characters" truncated to "Org name more than"
When I go to dataset page
Then I should see a search facet for "Org name more than 35 characters" truncated to "Org name more than"
When I press the search facet pointing to "Org name more than 35 characters"
Then I should see an active search facet for "Org name more than 35 characters" truncated to "Org name more than"
21 changes: 21 additions & 0 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ def request_reset(context):
""")


@then(u'I should see a search facet for "{title}" truncated to "{truncated_title}"')
def truncated_facet_visible(context, title, truncated_title):
context.execute_steps(u"""
Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), '{truncated_title}') and contains(string(), '...') and (contains(@title, '{title}') or contains(@data-bs-title, '{title}'))]"
""".format(title=title, truncated_title=truncated_title))


@then(u'I should see an active search facet for "{title}" truncated to "{truncated_title}"')
def active_truncated_facet_visible(context, title, truncated_title):
context.execute_steps(u"""
Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), '{truncated_title}') and contains(string(), '...') and (contains(@title, '{title}') or contains(@data-bs-title, '{title}'))]"
""".format(title=title, truncated_title=truncated_title))


@when(u'I press the search facet pointing to "{title}"')
def press_search_facet(context, title):
context.execute_steps(u"""
When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(@title, '{0}') or contains(@data-bs-title, '{0}')]"
""".format(title))


@when(u'I fill in "{name}" with "{value}" if present')
def fill_in_field_if_present(context, name, value):
context.execute_steps(u"""
Expand Down
10 changes: 10 additions & 0 deletions test/features/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ Feature: User APIs
Then I should see my datasets
And I should see "Add Dataset"

Scenario: Dashboard news feed can display organisational changes
Given "SysAdmin" as the persona
When I log in
And I go to organisation page
And I press "Test Organisation"
And I press "Manage"
And I press "Update"
And I visit "/dashboard"
Then I should see an element with xpath "//li[contains(string(), 'updated the organisation')]/a[contains(string(), 'Test Organisation') and contains(@href, '/organization/')]/..//a[contains(string(), 'Administrator') and @href='/user/admin']"

@email
Scenario: As a registered user, when I have locked my account with too many failed logins, I can reset my password to unlock it
Given "CKANUser" as the persona
Expand Down

0 comments on commit 1820e93

Please sign in to comment.