Skip to content

Commit

Permalink
Cover the case when ordering descriptor is specified as a list of mod…
Browse files Browse the repository at this point in the history
…el fields
  • Loading branch information
earshinov committed Dec 24, 2019
1 parent 0e147cc commit 11c653c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,12 +1686,24 @@ def test_params_as_list_of_tuples_with_string(self):
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_list_of_tuples_with_strings(self):
f = OrderingFilter(
params=[('user', ('username',))]
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_list_of_tuples_with_expression(self):
f = OrderingFilter(
params=[('user', F('username'))]
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_list_of_tuples_with_expressions(self):
f = OrderingFilter(
params=[('user', (F('username'),))]
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_list_of_tuples_with_descriptor_and_string(self):
f = OrderingFilter(
params=[('user', {'expr': 'username'})]
Expand Down Expand Up @@ -1722,12 +1734,24 @@ def test_params_as_dict_with_string(self):
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_dict_with_strings(self):
f = OrderingFilter(
params={'user': ('username',)}
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_dict_with_expression(self):
f = OrderingFilter(
params={'user': F('username')}
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_dict_with_expressions(self):
f = OrderingFilter(
params={'user': (F('username'),)}
)
self.assertEqual(f._params, OrderedDict((('user', {'exprs': [F('username')]}),)))

def test_params_as_dict_with_descriptor_and_string(self):
f = OrderingFilter(
params={'user': {'expr': 'username'}}
Expand Down

0 comments on commit 11c653c

Please sign in to comment.