phenoscape / rphenoscape

R package to make phenotypic traits from the Phenoscape Knowledgebase available from within R.
https://rphenoscape.phenoscape.org/
Other
5 stars 5 forks source link

Fix terminfo tests for API classification optimization #236

Closed johnbradley closed 2 years ago

johnbradley commented 3 years ago

When using the v2-beta2 API changes to /term endpoint cause a test to fail. The following line started failing: https://github.com/phenoscape/rphenoscape/blob/531601b13fa80fdb8859252bcaaf3eaee4719abc/tests/testthat/test-pk.R#L208

The above line tests that as.terminfo() doesn't fetch classification data when not using withClassification. In the v2-beta2 release an optimization has been made to the underlying /term API endpoint to always return classification data.

Another aspect of the changed /term API endpoint is when a term is not found the classification structure is now filled in with empty lists. Example:

> obj <- as.terminfo("foo")
Warning message:
Failed to retrieve term for IRI foo 
> str(obj$classification)
List of 3
 $ subClassOf  : Named list()
 $ superClassOf: Named list()
 $ equivalentTo: Named list()

This causes another failure in the same test where the code expects obj$classification to be NULL for a bogus term: https://github.com/phenoscape/rphenoscape/blob/531601b13fa80fdb8859252bcaaf3eaee4719abc/tests/testthat/test-pk.R#L222-L226

See https://github.com/phenoscape/phenoscape-kb-services/issues/413 for details on the /term endpoint changes.

This is part of #235