'Same test as the one above but rather function directly, we call
management command instead.'

def test_clean_perms_command(self):

    target_perms = {self.target_user1: [(u'change_%s' % user_module_name)], self.target_group1: [u'delete_group'], self.target_obj1: [u'change_contenttype', u'delete_contenttype'], self.target_obj2: [u'change_contenttype']}
    for (target, perms) in target_perms.items():
        target.__old_pk = target.pk
        for perm in perms:
            assign_perm(perm, self.user, target)
    for (target, perms) in target_perms.items():
        target.delete()
    call_command(u'clean_orphan_obj_perms', verbosity=0)
    for (target, perms) in target_perms.items():
        target.pk = target.__old_pk
        target.save()
        for perm in perms:
            self.assertFalse(self.user.has_perm(perm, target))
