Esempio n. 1
0
 def test_aggregate(self, mock_es):
     view = self.DemoView()
     view._auth_enabled = True
     view.Model = Mock(__name__="FooBar")
     aggregator = ESAggregator(view)
     aggregator.check_aggregations_privacy = Mock()
     aggregator.stub_wrappers = Mock()
     aggregator.pop_aggregations_params = Mock(return_value={"foo": 1})
     aggregator._query_params = {"q": "2", "zoo": 3}
     aggregator.aggregate()
     aggregator.stub_wrappers.assert_called_once_with()
     aggregator.pop_aggregations_params.assert_called_once_with()
     aggregator.check_aggregations_privacy.assert_called_once_with({"foo": 1})
     mock_es.assert_called_once_with("FooBar")
     mock_es().aggregate.assert_called_once_with(_aggregations_params={"foo": 1}, q="2", zoo=3)
Esempio n. 2
0
 def test_aggregate(self, mock_es):
     view = self.DemoView()
     view._auth_enabled = True
     view.Model = Mock(__name__='FooBar')
     aggregator = ESAggregator(view)
     aggregator.check_aggregations_privacy = Mock()
     aggregator.stub_wrappers = Mock()
     aggregator.pop_aggregations_params = Mock(return_value={'foo': 1})
     aggregator._query_params = {'q': '2', 'zoo': 3}
     aggregator.aggregate()
     aggregator.stub_wrappers.assert_called_once_with()
     aggregator.pop_aggregations_params.assert_called_once_with()
     aggregator.check_aggregations_privacy.assert_called_once_with(
         {'foo': 1})
     mock_es.assert_called_once_with('FooBar')
     mock_es().aggregate.assert_called_once_with(
         _aggregations_params={'foo': 1}, q='2', zoo=3)
Esempio n. 3
0
 def test_wrap(self):
     view = self.DemoView()
     view.index = Mock(__name__='foo')
     aggregator = ESAggregator(view)
     aggregator.aggregate = Mock(side_effect=KeyError)
     func = aggregator.wrap(view.index)
     func(1, 2)
     aggregator.aggregate.assert_called_once_with()
     view.index.assert_called_once_with(1, 2)
Esempio n. 4
0
 def test_wrap(self):
     view = self.DemoView()
     view.index = Mock(__name__="foo")
     aggregator = ESAggregator(view)
     aggregator.aggregate = Mock(side_effect=KeyError)
     func = aggregator.wrap(view.index)
     func(1, 2)
     aggregator.aggregate.assert_called_once_with()
     view.index.assert_called_once_with(1, 2)