Skip to content

Commit

Permalink
extend the functional tests, and make some tweaks as to the display o…
Browse files Browse the repository at this point in the history
…f some of the checks
  • Loading branch information
richard-jones committed Aug 18, 2023
1 parent 3c03cc6 commit 9e90a23
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 22 deletions.
34 changes: 25 additions & 9 deletions cms/sass/themes/_editorial-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,38 @@
color: $white;
}

.icon-container--unable_to_access {
background: $grapefruit;
.icon-container--success {
background: $mid-green;
}

.icon-container--not_found,
.icon-container--not_validated,
.icon-container--missing,
.icon-container--outdated {
.icon-container--error {
background: $sanguine;
}

.icon-container--fully_validated,
.icon-container--present {
background: $mid-green;
.icon-container--warn {
background: $grapefruit;
}

.icon-container--info {
background: $mid-grey;
}

//.icon-container--unable_to_access {
// background: $grapefruit;
//}
//
//.icon-container--not_found,
//.icon-container--not_validated,
//.icon-container--missing,
//.icon-container--outdated {
// background: $sanguine;
//}
//
//.icon-container--fully_validated,
//.icon-container--present {
// background: $mid-green;
//}

.parsley-errors-list {
padding: $spacing-03;
border-radius: $spacing-01;
Expand Down
57 changes: 50 additions & 7 deletions doajtest/testdrive/autocheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@ def setup(self) -> dict:
acc.set_password(pw)
acc.save()

##################################################
## Setup and Application with the following features
##
## - Print ISSN registered at ISSN.org
## - Electronic ISSN not registered at ISSN.org
## - 3 preservation services:
## - CLOCKSS - currently archived
## - LOCKSS - not currently archived
## - PMC - not registered
source = ApplicationFixtureFactory.make_application_source()
ap = models.Application(**source)
ap.application_type = constants.APPLICATION_TYPE_NEW_APPLICATION
ap.remove_current_journal()
ap.remove_related_journal()
apbj = ap.bibjson()
apbj.set_preservation(["CLOCKSS", "LOCKSS", "PMC", "PKP PN"], "http://policy.example.com")
ap.set_id(ap.makeid())
ap.save()

Expand All @@ -34,9 +45,9 @@ def setup(self) -> dict:

thisyear = datetime.utcnow().year

issn_data = ISSNOrgData({
pissn_data = ISSNOrgData({
"mainEntityOfPage": {
"version": "Register"
"version": "Register" # this means the ISSN is registered at ISSN.org
},
"subjectOf": [
{
Expand All @@ -51,7 +62,29 @@ def setup(self) -> dict:
"holdingArchive": {
"@id": "http://issn.org/organization/keepers#lockss"
},
"temporalCoverage": "2019/2020"
}
]
})

eissn_data = ISSNOrgData({
"mainEntityOfPage": {
"version": "Pending" # this means the ISSN is not registered at ISSN.org
},
"subjectOf": [
{
"@type": "ArchiveComponent",
"holdingArchive": {
"@id": "http://issn.org/organization/keepers#clockss"
},
"temporalCoverage": "2022/" + str(thisyear)
},
{
"@type": "ArchiveComponent",
"holdingArchive": {
"@id": "http://issn.org/organization/keepers#lockss"
},
"temporalCoverage": "2019/2020"
}
]
})
Expand All @@ -60,11 +93,11 @@ def setup(self) -> dict:
ISSNChecker.retrieve_from_source = lambda *args, **kwargs: (
eissn,
"https://portal.issn.org/resource/ISSN/2682-4396",
issn_data,
eissn_data,
False,
pissn,
"https://portal.issn.org/resource/ISSN/2682-4396",
issn_data,
pissn_data,
False)

acSvc = DOAJ.autochecksService(
Expand All @@ -76,6 +109,16 @@ def setup(self) -> dict:
)
ac1 = acSvc.autocheck_application(ap)

##################################################
## Setup a Journal with the following features
##
## - Print ISSN registered at ISSN.org
## - Electronic ISSN not found
## - 3 preservation services:
## - CLOCKSS - currently archived
## - LOCKSS - not currently archived
## - PMC - not registered

source = JournalFixtureFactory.make_journal_source()
j = models.Journal(**source)
j.remove_current_application()
Expand All @@ -88,12 +131,12 @@ def setup(self) -> dict:

ISSNChecker.retrieve_from_source = lambda *args, **kwargs: (
eissn,
"https://portal.issn.org/resource/ISSN/2682-4396",
issn_data,
"https://portal.issn.org/resource/ISSN/9999-000X",
None, # Don't pass in any data, so we get the Not Found response
False,
pissn,
"https://portal.issn.org/resource/ISSN/2682-4396",
issn_data,
pissn_data,
False)

ac2 = acSvc.autocheck_journal(j)
Expand Down
9 changes: 9 additions & 0 deletions portality/autocheck/checkers/keepers_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class KeepersRegistry(ISSNChecker):
MISSING = "missing"
PRESENT = "present"
OUTDATED = "outdated"
NOT_RECORDED = "not_recorded"

def _get_archive_components(self, eissn_data, pissn_data):
acs = []
Expand Down Expand Up @@ -62,6 +63,14 @@ def check(self, form: dict,
for service in services:
id = self.ID_MAP.get(service)
if not id:
logger("Service {x} is not recorded by Keepers Registry".format(x=service))
autochecks.add_check(
field="preservation_service",
advice=self.NOT_RECORDED,
reference_url=url,
context={"service": service},
checked_by=self.__identity__
)
continue

coverage = ad.get(id)
Expand Down
32 changes: 26 additions & 6 deletions portality/static/js/autochecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ doaj.autocheckers.ISSNActive = class {
"not_validated": "x-circle"
}

STYLE = {
"unable_to_access": "error",
"not_found": "error",
"fully_validated": "success",
"not_validated": "warn"
}

draw(autocheck) {
let icon = this.ICONS[autocheck.advice];
let message = this.MESSAGES[autocheck.advice];
message = message.replace("{{ISSN}}", autocheck.original_value);

let frag = `<div><span class="icon-container icon-container--${autocheck.advice}"><span data-feather="${icon}" aria-hidden="true"></span></span>
${message} (<a href="${autocheck.reference_url}" target="_blank">see record</a>).</div>`;
let style = this.STYLE[autocheck.advice];

let frag = `<div><span class="icon-container icon-container--${autocheck.advice} icon-container--${style}"><span data-feather="${icon}" aria-hidden="true"></span></span>
${message} (<a href="${autocheck.reference_url}" target="_blank">see record</a>)</div>`;
return frag;
}
}
Expand All @@ -32,13 +41,22 @@ doaj.autocheckers.KeepersRegistry = class {
MESSAGES = {
"missing": "Keepers does not show any content archived in {service}.",
"present": "The journal content is actively archived in {service}.",
"outdated": "The journal has content archived in {service} but it's not current."
"outdated": "The journal has content archived in {service} but it's not current.",
"not_recorded": "Keepers Registry does not currently record information about {service}."
}

ICONS = {
"missing": "x-circle",
"present": "check-circle",
"outdated": "x-circle"
"outdated": "x-circle",
"not_recorded": "info"
}

STYLE = {
"missing": "error",
"present": "success",
"outdated": "error",
"not_recorded": "info"
}

draw(autocheck) {
Expand All @@ -48,8 +66,10 @@ doaj.autocheckers.KeepersRegistry = class {
let context = JSON.parse(autocheck.context);
message = message.replace("{service}", context.service);

let frag = `<div><span class="icon-container icon-container--${autocheck.advice}"><span data-feather="${icon}" aria-hidden="true"></span></span>
${message} (<a href="${autocheck.reference_url}" target="_blank">see record</a>).</div>`;
let style = this.STYLE[autocheck.advice];

let frag = `<div><span class="icon-container icon-container--${autocheck.advice} icon-container--${style}""><span data-feather="${icon}" aria-hidden="true"></span></span>
${message} (<a href="${autocheck.reference_url}" target="_blank">see record</a>)</div>`;
return frag;
}
}
Expand Down

0 comments on commit 9e90a23

Please sign in to comment.