Skip to content

Commit

Permalink
YDA-5721: add tests for managing preservable file formats lists
Browse files Browse the repository at this point in the history
Co-authored-by: Lazlo Westerhof <[email protected]>
  • Loading branch information
leonidastri and lwesterhof authored Oct 17, 2024
1 parent e20a210 commit e21944f
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/features/ui/ui_admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,28 @@ Feature: Admin UI
Examples:
| user | text |
| functionaladminpriv | TemporaryTerms |


Scenario Outline: Admin user deletes file format
Given user <user> is logged in
When module "admin" is shown
And the user selects the file format list <filename> to delete
And the user clicks the Delete file format list button
Then the success message for deleting the file format list <filename> is shown

Examples:
| user | filename |
| functionaladminpriv | 4TU.json |
| functionaladminpriv | DANS.json |


Scenario Outline: Admin user uploads new file format
Given user <user> is logged in
When module "admin" is shown
And the user clicks the Upload file format list <filename>
Then the success message of uploading a file format list <filename> is shown

Examples:
| user | filename |
| functionaladminpriv | 4TU.json |
| functionaladminpriv | DANS.json |
35 changes: 35 additions & 0 deletions tests/files/file_formats/4TU.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "4TU Preferred formats",
"help": "Checks if the files in the data folder and subfolders comply with the 4TU Centre for Research Data guidelines for preferred file formats as per 1-Aug-2019. Their guidelines states that usage of the preferred file formats is of essential importance in order to ensure that the research data will remain usable in the future. For more information see https://researchdata.4tu.nl/. Disclaimer: Please note that Yoda currently deducts the file format from the filename. It does not inspect the file content.",
"advice": "For files that do not comply with preferred formats, we recommend that you include in the data package a specification of the file format. Should you want to reference an external specification document then try to find a sustainable link, ideally use a DOI. If feasible, also include in a separate folder of your data package a copy of the file transformed into of the preferred formats. Please consult a datamanager or consult the Research Support desk (see https://www.uu.nl/rdm) in case you need any assistance.",
"formats": [
"txt",
"xml",
"html",
"pdf",
"json",
"pdb",
"ent",
"brk",
"xyz",
"csv",
"jpg",
"jpeg",
"tif",
"tiff",
"png",
"svg",
"gml",
"kml",
"kmz",
"shp",
"shx",
"dbf",
"nc",
"wav",
"zip",
"tar",
"gzip",
"7z"
]
}
49 changes: 49 additions & 0 deletions tests/files/file_formats/DANS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "DANS Preferred formats",
"help": "Checks if the files in the data folder and subfolders comply with the DANS guidelines for preferred file formats as per 1-Aug-2019. Their guidelines states that the preferred file formats offer the best long-term guarantees in terms of usability, accessibility and sustainability. For more information see https://dans.knaw.nl/. Disclaimer: Please note that Yoda currently deducts the file format from the filename. It does not inspect the file content.",
"advice": "For files that do not comply with preferred formats, we recommend that you include in the data package a specification of the file format. Should you want to reference an external specification document then try to find a sustainable link, ideally use a DOI. If feasible, also include in a separate folder of your data package a copy of the file transformed into of the preferred formats. Please consult a datamanager or consult the Research Support desk (see https://www.uu.nl/rdm) in case you need any assistance.",
"formats": [
"pdf",
"odt",
"txt",
"xml",
"html",
"css",
"xslt",
"js",
"es",
"ods",
"csv",
"sql",
"siard",
"por",
"dta",
"jpg",
"jpeg",
"tif",
"tiff",
"png",
"jp2",
"dcm",
"svg",
"bwf",
"mxf",
"mka",
"flac",
"mxf",
"mkv",
"dxf",
"gml",
"mif",
"mid",
"asc",
"obj",
"ply",
"x3d",
"dae",
"rdf",
"trig",
"ttl",
"nt"
]
}
39 changes: 39 additions & 0 deletions tests/step_defs/ui/test_ui_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__copyright__ = "Copyright (c) 2024, Utrecht University"
__license__ = "GPLv3, see LICENSE"

import os
import time

from pytest_bdd import (
Expand Down Expand Up @@ -182,3 +183,41 @@ def ui_admin_removed_text_not_displayed(browser, text):
time.sleep(1)
terms = browser.find_by_id('admin-publication-terms').first.value
assert text not in terms


@when(parsers.parse('the user clicks the Upload file format list {filename}'))
def ui_admin_clicks_upload_file_format_button(browser, filename):
browser.execute_script("document.getElementById('upload-button').scrollIntoView();")
browser.find_by_css("#upload-button")

cwd = os.getcwd()
if os.name == 'nt':
browser.find_by_css('input[type="file"]')[0].fill("{}\\files\\file_formats\\{}".format(cwd, filename))
else:
browser.find_by_css('input[type="file"]')[0].fill("{}/files/file_formats/{}".format(cwd, filename))


@then(parsers.parse('the success message of uploading a file format list {filename} is shown'))
def ui_admin_upload_file_format_success(browser, filename):
assert browser.is_text_present(f"File format list '{filename}' uploaded successfully.")


@when(parsers.parse('the user selects the file format list {filename} to delete'))
def ui_admin_select_file_format(browser, filename):
browser.execute_script("document.getElementById('file-formats-list').scrollIntoView();")
browser.find_by_css('#file-formats-list').click()
options = browser.find_by_css('#file-formats-list option')
for option in options:
if option.value == filename.split('.')[0]:
option.click()
break


@when('the user clicks the Delete file format list button')
def ui_admin_click_delete_button(browser):
browser.find_by_css("#delete-format-button").click()


@then(parsers.parse('the success message for deleting the file format list {filename} is shown'))
def ui_admin_delete_file_format_success(browser, filename):
assert browser.is_text_present(f"File format list '{filename}' deleted successfully.")

0 comments on commit e21944f

Please sign in to comment.