Skip to content

Commit

Permalink
Removed reminescent queries that used the DbPath (#258). It was possi…
Browse files Browse the repository at this point in the history
…ble to simplify the code significantly, leading to a much cleaner API of the QB
  • Loading branch information
lekah committed Jul 21, 2017
1 parent c50653c commit ce48dc0
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 334 deletions.
29 changes: 21 additions & 8 deletions aiida/backends/tests/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ def test_tags(self):
qb.append(Node, tag='n1')
qb.append(Node, tag='n2', edge_tag='e1', output_of='n1')
qb.append(Node, tag='n3', edge_tag='e2', output_of='n2')
qb.append(Computer, computer_of='n3', tag='c1')
self.assertEqual(qb.get_used_tags(), ['n1', 'n2','e1', 'n3', 'e2', 'c1'])
qb.append(Computer, computer_of='n3', tag='c1', edge_tag='nonsense')
self.assertEqual(qb.get_used_tags(), ['n1', 'n2','e1', 'n3', 'e2', 'c1', 'nonsense'])


# Now I am testing the default tags,
Expand Down Expand Up @@ -753,10 +753,6 @@ def test_query_path(self):

n6.add_link_from(n5)
# Yet, now 2 links from 1 to 8




self.assertEquals(
QueryBuilder().append(
Node, filters={'id':n1.pk}, tag='anc'
Expand All @@ -770,7 +766,24 @@ def test_query_path(self):
).append(Node, ancestor_of='desc', filters={'id':n1.pk}
).count(), 2)

qb = QueryBuilder(expand_path=True).append(
self.assertEquals(
QueryBuilder().append(
Node, filters={'id':n8.pk}, tag='desc'
).append(Node, ancestor_of='desc', filters={'id':n1.pk}, edge_filters={'depth':{'<':6}},
).count(), 2)
self.assertEquals(
QueryBuilder().append(
Node, filters={'id':n8.pk}, tag='desc'
).append(Node, ancestor_of='desc', filters={'id':n1.pk}, edge_filters={'depth':5},
).count(), 2)
self.assertEquals(
QueryBuilder().append(
Node, filters={'id':n8.pk}, tag='desc'
).append(Node, ancestor_of='desc', filters={'id':n1.pk}, edge_filters={'depth':{'<':5}},
).count(), 0)

# TODO write a query that can filter certain paths by traversed ID
qb = QueryBuilder().append(
Node, filters={'id':n8.pk}, tag='desc',
).append(Node, ancestor_of='desc', edge_project='path', filters={'id':n1.pk})
queried_path_set = set([frozenset(p) for p, in qb.all()])
Expand All @@ -782,7 +795,7 @@ def test_query_path(self):

self.assertTrue(queried_path_set == paths_there_should_be)

qb = QueryBuilder(expand_path=True).append(
qb = QueryBuilder().append(
Node, filters={'id':n1.pk}, tag='anc'
).append(
Node, descendant_of='anc', filters={'id':n8.pk}, edge_project='path'
Expand Down
Loading

0 comments on commit ce48dc0

Please sign in to comment.