Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed Oct 7, 2022
1 parent 3edd604 commit 7016e3e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion __test__/integration/TRAPIGeneralizedQuery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Testing TRAPI QueryHandler Generalized Query Handling", () => {

describe("Testing query function", () => {
test.skip("One hop has only nodes specified", async (done) => {
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler();
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({});
queryHandler.setQueryGraph(OneHopQuery);
await queryHandler.query();
let res = queryHandler.getResponse();
Expand Down
2 changes: 1 addition & 1 deletion __test__/integration/TRAPIQueryHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Testing TRAPIQueryHandler Module", () => {
};
describe("Testing query function", () => {
test("test with one query edge", async () => {
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler();
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({});
queryHandler.setQueryGraph(OneHopQuery);
await queryHandler.query();
expect(queryHandler.knowledgeGraph.kg).toHaveProperty('nodes');
Expand Down
6 changes: 3 additions & 3 deletions __test__/integration/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Testing TRAPIQueryHandler Module", () => {
//skip until we figure out why it returns no results
//https://suwulab.slack.com/archives/CC218TEKC/p1624558136437200
test.skip("When looking for chemicals affected by Phenotype Increased Urinary Glycerol, Glycerol should pop up", async () => {
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true);
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, {}, undefined, undefined, true);
const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'increased_urinary_glycerol_affects_glycerol.json')));
queryHandler.setQueryGraph(query.message.query_graph);
await queryHandler.query();
Expand All @@ -17,7 +17,7 @@ describe("Testing TRAPIQueryHandler Module", () => {
})

test("When looking for genes related to Disease DYSKINESIA, FAMILIAL, WITH FACIAL MYOKYMIA, ACDY5 should pop up", async () => {
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true);
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, {}, undefined, undefined, true);
const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'FDFM_caused_by_ACDY5.json')));
queryHandler.setQueryGraph(query.message.query_graph);
await queryHandler.query();
Expand All @@ -27,7 +27,7 @@ describe("Testing TRAPIQueryHandler Module", () => {

//skip this test for now as the test query needs to be re-evaluated and the value of 'CHEBI:3962' needs to be updated.
test.skip("When looking for chemicals targeting IL1 Signaling patway, curcumin should pop up", async () => {
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true);
const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, {}, undefined, undefined, true);
const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'chemicals_targeting_IL1_Signaling_Pathway.json')));
queryHandler.setQueryGraph(query.message.query_graph);
await queryHandler.query();
Expand Down
2 changes: 1 addition & 1 deletion src/inferred_mode/inferred_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module.exports = async (parent, TRAPIQueryHandler, queryGraph, logs, options, pa
if (stop) {
return;
}
const handler = new TRAPIQueryHandler(options, path, predicatePath, includeReasoner);
const handler = new TRAPIQueryHandler({}, options, path, predicatePath, includeReasoner);
handler.setQueryGraph(queryGraph);
try {
await handler.query();
Expand Down
6 changes: 4 additions & 2 deletions src/query_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ module.exports = class QueryGraphHandler {
}

_validateNodeProperties(queryGraph) {
const nodeProperties = new Set(Object.keys(this.schema.components.schemas.QNode.properties));
const schemProps = this.schema?.components?.schemas?.QNode?.properties ? this.schema.components.schemas.QNode.properties : {};
const nodeProperties = new Set(Object.keys(schemProps));
const badProperties = new Set();
for (const nodeID in queryGraph.nodes) {
for (const property in queryGraph.nodes[nodeID]) {
Expand All @@ -107,7 +108,8 @@ module.exports = class QueryGraphHandler {
}

_validateEdgeProperties(queryGraph) {
const edgeProperties = new Set(Object.keys(this.schema.components.schemas.QEdge.properties));
const schemProps = this.schema?.components?.schemas?.QEdge?.properties ? this.schema.components.schemas.QEdge.properties : {};
const edgeProperties = new Set(Object.keys(schemProps));
const badProperties = new Set();
for (const edgeID in queryGraph.edges) {
for (const property in queryGraph.edges[edgeID]) {
Expand Down

0 comments on commit 7016e3e

Please sign in to comment.