def test_find_by_ace(self, mock_types, mock_body, mock_es): mock_types.return_value = 'Foo,Bar' mock_body.return_value = {'username': '******'} result = acl_utils.find_by_ace(1, 2, True) mock_types.assert_called_once_with(2) mock_body.assert_called_once_with(1) mock_es.assert_called_once_with('Foo,Bar') mock_es().get_collection.assert_called_once_with( _count=True, body={'username': '******'}) assert result == mock_es().get_collection()
def test_find_by_ace_not_es(self, mock_types): mock_types.return_value = [] with pytest.raises(ValueError) as ex: assert acl_utils.find_by_ace({}, 1) assert 'No es-based models passed' in str(ex.value)