def login_with_permissions(self, *codenames):
        perms = Permission.objects.filter(codename__in=codenames)
        self.perm_user = factories.User()
        self.perm_user.user_permissions.add(*perms)
        self.perm_user.save()
        self.login_user(self.perm_user)
Helper to login as a user with correct permissions
dataset/ETHPy150Open caktus/django-timepiece/timepiece/entries/tests/test_timesheet.py/StatusTest.login_with_permissions