MCPcopy Index your code
hub / github.com/clips/pattern / test_group

Method test_group

test/test_db.py:663–679  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

661 print "pattern.db.cmp()"
662
663 def test_group(self):
664 # Assert WHERE with AND/OR combinations from Group object().
665 yesterday = db.date()
666 yesterday -= db.time(days=1)
667 g1 = db.Group(("name", "garlic bread"))
668 g2 = db.Group(("name", "pizza"), ("price", 10, "<"), operator=db.AND)
669 g3 = db.Group(g1, g2, operator=db.OR)
670 g4 = db.Group(g3, ("date", yesterday, ">"), operator=db.AND)
671 self.assertEqual(g1.SQL(), "name='garlic bread'")
672 self.assertEqual(g2.SQL(), "name='pizza' and price<10")
673 self.assertEqual(g3.SQL(), "(name='garlic bread') or (name='pizza' and price<10)")
674 self.assertEqual(g4.SQL(), "((name='garlic bread') or (name='pizza' and price<10)) and date>'%s'" % yesterday)
675 # Assert subquery in group.
676 q = self._query(fields=["name"])
677 g = db.any(("name", u"Gödel"), ("name", q))
678 self.assertEqual(g.SQL(), u"name='Gödel' or name in (select persons.name from `persons`)")
679 print "pattern.db.Group"
680
681 def test_query(self):
682 # Assert table query results from Table.search().

Callers

nothing calls this directly

Calls 3

SQLMethod · 0.95
_queryMethod · 0.95
dateMethod · 0.80

Tested by

no test coverage detected