'Ensures that a permission that cannot be parsed or resolved results in
and error and that no persistent state is changed.'

@ddt.data(*TEST_DATA)
def test_invalid_permission(self, initial_group_permissions):

    self.set_group_permissions(initial_group_permissions)
    with self.assertRaises(CommandError) as exc_context:
        call_command('manage_group', TEST_GROUP, '--permissions', 'fail')
    self.assertIn('invalid    permission    option', str(exc_context.exception).lower())
    self.check_group_permissions(initial_group_permissions)
    with self.assertRaises(CommandError) as exc_context:
        call_command('manage_group', TEST_GROUP, '--permissions', 'f:a:i:l')
    self.assertIn('invalid    permission    option', str(exc_context.exception).lower())
    self.check_group_permissions(initial_group_permissions)
    with self.assertRaises(CommandError) as exc_context:
        call_command('manage_group', TEST_GROUP, '--permissions', 'nonexistent-label:dummy-model:dummy-perm')
    self.assertIn('no    installed    app', str(exc_context.exception).lower())
    self.assertIn('nonexistent-label', str(exc_context.exception).lower())
    self.check_group_permissions(initial_group_permissions)
    with self.assertRaises(CommandError) as exc_context:
        call_command('manage_group', TEST_GROUP, '--permissions', 'auth:nonexistent-model:dummy-perm')
    self.assertIn('nonexistent-model', str(exc_context.exception).lower())
    self.check_group_permissions(initial_group_permissions)
    with self.assertRaises(CommandError) as exc_context:
        call_command('manage_group', TEST_GROUP, '--permissions', 'auth:Group:nonexistent-perm')
    self.assertIn('invalid    permission    codename', str(exc_context.exception).lower())
    self.assertIn('nonexistent-perm', str(exc_context.exception).lower())
    self.check_group_permissions(initial_group_permissions)
