def test_count_ace_with_models(self, mock_find, mock_eng): result = acl_utils.count_ace(1, [2, 3]) mock_find.assert_has_calls([ call(1, [2], count=True), call(1, [3], count=True)]) assert not mock_eng.get_document_classes.called assert result == {2: mock_find(), 3: mock_find()}
def test_count_ace_with_models(self, mock_find, mock_eng): result = acl_utils.count_ace(1, [2, 3]) mock_find.assert_has_calls( [call(1, [2], count=True), call(1, [3], count=True)]) assert not mock_eng.get_document_classes.called assert result == {2: mock_find(), 3: mock_find()}
def run(self): if self.options.models: model_names = split_strip(self.options.models) models = [engine.get_document_cls(name) for name in model_names] else: models = None try: ace = json.loads(self.options.ace) except ValueError as ex: raise ValueError('--ace: {}'.format(ex)) counts = count_ace(ace=ace, models=models) six.print_('Model,Count') for model, count in counts.items(): if count is None: count = 'Not es-based' six.print_('{},{}'.format(model.__name__, count))
def test_count_ace_valueerror(self, mock_find): mock_find.side_effect = ValueError result = acl_utils.count_ace(1, [2]) assert result == {2: None}
def test_count_ace_without_models(self, mock_find, mock_eng): mock_eng.get_document_classes.return_value = {'zoo': 2} acl_utils.count_ace(1) mock_find.assert_called_with(1, [2], count=True)