1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 from mock
import MagicMock
19 from indico
.util
.user
import iter_acl
, unify_user_args
23 user
= MagicMock(is_group
=False, spec
=['is_group'])
24 local_group
= MagicMock(is_group
=True, is_local
=True)
25 remote_group
= MagicMock(is_group
=True, is_local
=False)
26 acl
= [remote_group
, user
, local_group
]
27 assert list(iter_acl(iter(acl
))) == [user
, local_group
, remote_group
]
30 def test_unify_user_args_new(dummy_avatar
):
32 user
= dummy_avatar
.user
35 def fn(a
, b
, c
, d
, e
, f
):
45 fn('foo', user
, avatar
, d
='bar', e
=user
, f
=avatar
)
48 def test_unify_user_args_legacy(dummy_avatar
):
50 user
= dummy_avatar
.user
52 @unify_user_args(legacy
=True)
53 def fn(a
, b
, c
, d
, e
, f
):
63 fn('foo', user
, avatar
, d
='bar', e
=user
, f
=avatar
)