Skip to content

Commit

Permalink
[QOLDEV-954] sync test config with other repos
Browse files Browse the repository at this point in the history
- Prepare test assertions to handle CKAN 2.11
- Refactor usability rating check into its own step
  • Loading branch information
ThrawnCA committed Nov 27, 2024
1 parent 529c157 commit 5641abd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/features/data_usability_rating.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Feature: Data usability rating
And I create a dataset and resource with key-value parameters "license=other-open" and "format=<Format>::upload=<Filename>"
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 see "Data usability rating"
Then I should see data usability rating <Score>
When I press "Test Resource"
Then I should see an element with xpath "//div[contains(@class, 'qa openness-<Score>')]"
Then I should see data usability rating <Score>

Examples: Formats
| Format | Filename | Score |
Expand Down
31 changes: 21 additions & 10 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def log_in_directly(context):
:return:
"""

assert context.persona, "A persona is required to log in, found [{}] in context. Have you configured the personas in before_scenario?".format(context.persona)
assert context.persona, "A persona is required to log in, found [{}] in context." \
" Have you configured the personas in before_scenario?".format(context.persona)
context.execute_steps(u"""
When I attempt to log in with password "$password"
Then I should see an element with xpath "//*[@title='Log out']/i[contains(@class, 'fa-sign-out')]"
Then I should see an element with xpath "//*[@title='Log out' or @data-bs-title='Log out']/i[contains(@class, 'fa-sign-out')]"
""")


Expand Down Expand Up @@ -187,9 +188,13 @@ def go_to_new_resource_form(context, name):
""")
else:
# Existing dataset, browse to the resource form
if context.browser.is_element_present_by_xpath(
"//a[contains(string(), 'Resources') and contains(@href, '/dataset/resources/')]"):
context.execute_steps(u"""
When I press "Resources"
""")
context.execute_steps(u"""
When I press "Resources"
And I press "Add new resource"
When I press "Add new resource"
And I take a debugging screenshot
""")

Expand Down Expand Up @@ -548,7 +553,7 @@ def create_resource_from_params(context, resource_params):
""".format(key, value))
context.execute_steps(u"""
When I take a debugging screenshot
And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]"
And I press the element with xpath "//form[contains(@data-module, 'resource-form')]//button[contains(@class, 'btn-primary')]"
And I take a debugging screenshot
""")

Expand All @@ -569,11 +574,7 @@ def filter_contents(mail):
payload_bytes = quopri.decodestring(payload)
if len(payload_bytes) > 0:
payload_bytes += b'=' # do fix the padding error issue
if six.PY2:
decoded_payload = payload_bytes.decode('base64')
else:
import base64
decoded_payload = six.ensure_text(base64.b64decode(six.ensure_binary(payload_bytes)))
decoded_payload = six.ensure_text(base64.b64decode(six.ensure_binary(payload_bytes)))
print('Searching for', text, ' and ', text2, ' in decoded_payload: ', decoded_payload)
return text in decoded_payload and (not text2 or text2 in decoded_payload)

Expand Down Expand Up @@ -792,6 +793,16 @@ def go_to_data_request_comments(context, subject):
""" % (subject))


# ckanext-qa


@then(u'I should see data usability rating {score}')
def data_usability_rating_visible(context, score):
context.execute_steps(u"""
Then I should see an element with xpath "//div[contains(@class, 'openness-{0}')]"
""".format(score))


# ckanext-report


Expand Down

0 comments on commit 5641abd

Please sign in to comment.