Skip to content

Commit

Permalink
Now with updated and working graph restriction test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniwelter committed Aug 21, 2018
1 parent f5ef0c2 commit 7772c81
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/objects/graphRestriction_normal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"text": "normal",
"ontology": "PATO:0000461"
}
4 changes: 2 additions & 2 deletions examples/schemas/graphRestriction-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"type": "string",
"graph_restriction": {
"ontologies" : ["obo:mondo", "obo:efo"],
"classes": ["http://purl.obolibrary.org/obo/MONDO_0000001","http://purl.obolibrary.org/obo/PATO_0000461"],
"classes": ["MONDO:0000001","PATO:0000461"],
"relations": ["rdfs:subClassOf"],
"direct": false,
"include_self": false
"include_self": true
}
},
"ontology_label": {
Expand Down
5 changes: 3 additions & 2 deletions src/custom/graph_restriction.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ module.exports = function graph_restriction(ajv) {
let errors = [];

if(parentTerms && ontologyIds) {
if(schema.include_self == True && parentTerms.includes(data)){
logger.log("debug", "It's a child term!");
if(schema.include_self == true && parentTerms.includes(data)){
logger.log("debug", "Acceptable parent term");
resolve(data);
}
else {

Expand Down
12 changes: 12 additions & 0 deletions test/graphRestriction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ test(" -> graphRestriction Schema", () => {
});
});

test(" -> graphRestriction Schema", () => {
let inputSchema = fs.readFileSync("examples/schemas/graphRestriction-schema.json");
let jsonSchema = JSON.parse(inputSchema);

let inputObj = fs.readFileSync("examples/objects/graphRestriction_normal.json");
let jsonObj = JSON.parse(inputObj);

return runValidation.validateSingleSchema(jsonSchema, jsonObj).then( (data) => {
expect(data).toBeDefined();
});
});

test(" -> graphRestriction Schema", () => {
let inputSchema = fs.readFileSync("examples/schemas/graphRestriction-schema.json");
let jsonSchema = JSON.parse(inputSchema);
Expand Down

0 comments on commit 7772c81

Please sign in to comment.