Exemple #1
0
 def test_paginate_query_default_sorts_dir_by_desc(self,
                                                   mock_paginate_query):
     query = mock.Mock()
     model = mock.Mock()
     db_api._paginate_query(self.ctx, query, model, sort_dir=None)
     args, _ = mock_paginate_query.call_args
     self.assertIn('asc', args)
Exemple #2
0
 def test_paginate_query_uses_given_sort_plus_id(self,
                                                 mock_paginate_query):
     query = mock.Mock()
     model = mock.Mock()
     db_api._paginate_query(self.ctx, query, model, sort_keys=['name'])
     args, _ = mock_paginate_query.call_args
     self.assertIn(['name', 'id'], args)
Exemple #3
0
    def test_paginate_query_gets_model_marker(self, mock_query,
                                              mock_paginate_query):
        query = mock.Mock()
        model = mock.Mock()
        marker = mock.Mock()

        mock_query_object = mock.Mock()
        mock_query_object.get.return_value = 'real_marker'
        mock_query.return_value = mock_query_object

        db_api._paginate_query(self.ctx, query, model, marker=marker)
        mock_query_object.get.assert_called_once_with(marker)
        args, _ = mock_paginate_query.call_args
        self.assertIn('real_marker', args)