forked from DGNum/gestioCOF
Avoid using get_by_natural_key
This commit is contained in:
parent
64c792b11f
commit
1f945d1af3
3 changed files with 15 additions and 9 deletions
|
@ -15,8 +15,8 @@ def make_user(name):
|
|||
|
||||
|
||||
def make_staff_user(name):
|
||||
view_event_perm = Permission.objects.get_by_natural_key(
|
||||
codename="view_event", app_label="events", model="event"
|
||||
view_event_perm = Permission.objects.get(
|
||||
codename="view_event", content_type__app_label="events",
|
||||
)
|
||||
user = make_user(name)
|
||||
user.user_permissions.add(view_event_perm)
|
||||
|
|
|
@ -84,7 +84,9 @@ class OpenKfetTest(ChannelTestCase):
|
|||
def test_export_team(self):
|
||||
"""Export all values for a team member."""
|
||||
user = User.objects.create_user("team", "", "team")
|
||||
is_team = Permission.objects.get_by_natural_key("is_team", "kfet", "account")
|
||||
is_team = Permission.objects.get(
|
||||
codename="is_team", content_type__app_label="kfet"
|
||||
)
|
||||
user.user_permissions.add(is_team)
|
||||
export = self.kfet_open.export(user)
|
||||
self.assertSetEqual(set(["status", "admin_status", "force_close"]), set(export))
|
||||
|
@ -115,11 +117,11 @@ class OpenKfetViewsTest(ChannelTestCase):
|
|||
|
||||
# get some permissions
|
||||
perms = {
|
||||
"kfet.is_team": Permission.objects.get_by_natural_key(
|
||||
"is_team", "kfet", "account"
|
||||
"kfet.is_team": Permission.objects.get(
|
||||
codename="is_team", content_type__app_label="kfet"
|
||||
),
|
||||
"kfet.can_force_close": Permission.objects.get_by_natural_key(
|
||||
"can_force_close", "kfet", "account"
|
||||
"kfet.can_force_close": Permission.objects.get(
|
||||
codename="can_force_close", content_type__app_label="kfet"
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -204,7 +206,9 @@ class OpenKfetConsumerTest(ChannelTestCase):
|
|||
"""Team user is added to kfet.open.team group."""
|
||||
# setup team user and its client
|
||||
t = User.objects.create_user("team", "", "team")
|
||||
is_team = Permission.objects.get_by_natural_key("is_team", "kfet", "account")
|
||||
is_team = Permission.objects.get(
|
||||
codename="is_team", content_type__app_label="kfet"
|
||||
)
|
||||
t.user_permissions.add(is_team)
|
||||
c = WSClient()
|
||||
c.force_login(t)
|
||||
|
|
|
@ -18,7 +18,9 @@ class TestStats(TestCase):
|
|||
user.set_password("foobar")
|
||||
user.save()
|
||||
Account.objects.create(trigramme="FOO", cofprofile=user.profile)
|
||||
perm = Permission.objects.get_by_natural_key("is_team", "kfet", "account")
|
||||
perm = Permission.objects.get(
|
||||
codename="is_team", content_type__app_label="kfet"
|
||||
)
|
||||
user.user_permissions.add(perm)
|
||||
|
||||
user2 = User.objects.create(username="Barfoo")
|
||||
|
|
Loading…
Reference in a new issue