Skip to content

Commit

Permalink
test(cognitarium): add test case for 'delete where {}' form
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Aug 10, 2023
1 parent c9ad451 commit 1cd850d
Showing 1 changed file with 88 additions and 72 deletions.
160 changes: 88 additions & 72 deletions contracts/okp4-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,20 +639,18 @@ mod tests {
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/dataverse/dataspace/metadata/unknown"
.to_string(),
))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/dataverse/dataspace/metadata/unknown"
.to_string(),
))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}))],
},
0,
),
Expand All @@ -668,17 +666,15 @@ mod tests {
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}))],
},
1,
),
Expand All @@ -703,17 +699,15 @@ mod tests {
"thesaurus:Test".to_string(),
))),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Prefixed(
"core:hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Prefixed(
"thesaurus:Test".to_string(),
))),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Prefixed(
"core:hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Prefixed(
"thesaurus:Test".to_string(),
))),
}))],
},
1,
),
Expand All @@ -736,15 +730,13 @@ mod tests {
))),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Prefixed(
"core:hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Node(NamedNode(Prefixed(
"core:hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}))],
},
1,
),
Expand All @@ -756,13 +748,23 @@ mod tests {
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}))],
},
11,
),
(
DeleteData {
prefixes: vec![],
delete: vec![],
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(id.to_string()))),
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}))],
},
11,
),
Expand Down Expand Up @@ -823,17 +825,15 @@ mod tests {
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Prefixed("foo:bar".to_string()))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Prefixed("foo:bar".to_string()))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}))],
},
expected: StdError::generic_err("Malformed prefixed IRI: prefix not found").into(),
},
Expand All @@ -847,18 +847,34 @@ mod tests {
predicate: VarOrNode::Variable("z".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}],
r#where: Some(vec![WhereCondition::Simple(TriplePattern(
msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
},
))]),
r#where: vec![WhereCondition::Simple(TriplePattern(msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
predicate: VarOrNode::Variable("p".to_string()),
object: VarOrNodeOrLiteral::Variable("o".to_string()),
}))],
},
expected: StdError::generic_err("Selected variable not found in query").into(),
},
TC {
command: DeleteData {
prefixes: vec![],
delete: vec![msg::TriplePattern {
subject: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
predicate: VarOrNode::Node(NamedNode(Full(
"https://ontology.okp4.space/core/hasTopic".to_string(),
))),
object: VarOrNodeOrLiteral::Node(NamedNode(Full(
"https://ontology.okp4.space/thesaurus/topic/Test".to_string(),
))),
}],
r#where: vec![],
},
expected: StdError::generic_err("Empty basic graph pattern").into(),
},
];

for case in cases {
Expand Down

0 comments on commit 1cd850d

Please sign in to comment.