mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
6823b09406
commit
630b40038e
2 changed files with 38 additions and 13 deletions
|
|
@ -67,17 +67,39 @@ def test_custom_json_encoder(obj, expected):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('args,expected_where,expected_params', [
|
||||
({
|
||||
'name_english__contains': ['foo'],
|
||||
}, '"name_english" like ?', ['%foo%']),
|
||||
({
|
||||
'foo': ['bar'],
|
||||
'bar__contains': ['baz'],
|
||||
}, '"bar" like ? and "foo" = ?', ['%baz%', 'bar']),
|
||||
({
|
||||
'foo__startswith': ['bar'],
|
||||
'bar__endswith': ['baz'],
|
||||
}, '"bar" like ? and "foo" like ?', ['%baz', 'bar%']),
|
||||
(
|
||||
{
|
||||
'name_english__contains': ['foo'],
|
||||
},
|
||||
'"name_english" like ?',
|
||||
['%foo%']
|
||||
),
|
||||
(
|
||||
{
|
||||
'foo': ['bar'],
|
||||
'bar__contains': ['baz'],
|
||||
},
|
||||
'"bar" like ? and "foo" = ?',
|
||||
['%baz%', 'bar']
|
||||
),
|
||||
(
|
||||
{
|
||||
'foo__startswith': ['bar'],
|
||||
'bar__endswith': ['baz'],
|
||||
},
|
||||
'"bar" like ? and "foo" like ?',
|
||||
['%baz', 'bar%']
|
||||
),
|
||||
(
|
||||
{
|
||||
'foo__lt': ['1'],
|
||||
'bar__gt': ['2'],
|
||||
'baz__gte': ['3'],
|
||||
'bax__lte': ['4'],
|
||||
},
|
||||
'"bar" > ? and "bax" <= ? and "baz" >= ? and "foo" < ?',
|
||||
['2', '4', '3', '1']
|
||||
),
|
||||
])
|
||||
def test_build_where(args, expected_where, expected_params):
|
||||
actual_where, actual_params = app.build_where_clause(args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue