lbry-sdk/tests/unit/test_database.py

24 lines
606 B
Python
Raw Normal View History

2018-08-04 03:26:53 +02:00
from unittest import TestCase
from torba.basedatabase import constraints_to_sql
class TestConstraintBuilder(TestCase):
def test_any(self):
constraints = {
'ages__any': {
'age__gt': 18,
'age__lt': 38
}
}
self.assertEqual(
constraints_to_sql(constraints, prepend_sql=''),
'(age > :ages__any_age__gt OR age < :ages__any_age__lt)'
)
self.assertEqual(
constraints, {
'ages__any_age__gt': 18,
'ages__any_age__lt': 38
}
)