示例#1
0
 def test_pop_aggregations_params_query_string(self):
     view = self.DemoView()
     view._query_params = {'test_aggregations.foo': 1, 'bar': 2}
     aggregator = ESAggregator(view)
     params = aggregator.pop_aggregations_params()
     assert params == {'foo': 1}
     assert aggregator._query_params == {'bar': 2}
示例#2
0
 def test_pop_aggregations_params_query_string(self):
     view = self.DemoView()
     view._query_params = {"test_aggregations.foo": 1, "bar": 2}
     aggregator = ESAggregator(view)
     params = aggregator.pop_aggregations_params()
     assert params == {"foo": 1}
     assert aggregator._query_params == {"bar": 2}
示例#3
0
 def test_pop_aggregations_params_keys_order(self):
     view = self.DemoView()
     view._query_params = {"test_aggregations.foo": 1, "foobar": 2}
     aggregator = ESAggregator(view)
     aggregator._aggregations_keys = ("test_aggregations", "foobar")
     params = aggregator.pop_aggregations_params()
     assert params == {"foo": 1}
     assert aggregator._query_params == {"foobar": 2}
示例#4
0
 def test_pop_aggregations_params_keys_order(self):
     view = self.DemoView()
     view._query_params = {
         'test_aggregations.foo': 1,
         'foobar': 2,
     }
     aggregator = ESAggregator(view)
     aggregator._aggregations_keys = ('test_aggregations', 'foobar')
     params = aggregator.pop_aggregations_params()
     assert params == {'foo': 1}
     assert aggregator._query_params == {'foobar': 2}
示例#5
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)
示例#6
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)
示例#7
0
 def test_pop_aggregations_params_mey_error(self):
     view = self.DemoView()
     aggregator = ESAggregator(view)
     with pytest.raises(KeyError) as ex:
         aggregator.pop_aggregations_params()
     assert 'Missing aggregation params' in str(ex.value)
示例#8
0
 def test_pop_aggregations_params_mey_error(self):
     view = self.DemoView()
     aggregator = ESAggregator(view)
     with pytest.raises(KeyError) as ex:
         aggregator.pop_aggregations_params()
     assert "Missing aggregation params" in str(ex.value)