From faa9531194cd3657ce1e2f40e6e8067ac546958c Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 3 Jan 2015 12:16:31 +0100 Subject: [PATCH] Task: Check that we are unable to set read only values through __init__ --- tasklib/task.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasklib/task.py b/tasklib/task.py index f7afbf2..3a58e50 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -132,6 +132,11 @@ class Task(TaskResource): def __init__(self, warrior, **kwargs): self.warrior = warrior + # Check that user is not able to set read-only value in __init__ + for key in kwargs.keys(): + if key in self.read_only_fields: + raise RuntimeError('Field \'%s\' is read-only' % key) + # We serialize the data in kwargs so that users of the library # do not have to pass different data formats via __setitem__ and # __init__ methods, that would be confusing -- 2.39.5