X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/228ef69b3f641c8bb81d7377977b9b57855f8572..6d756a70ec4367515bf0ec9eed7ef5b45418727d:/tasklib/tests.py diff --git a/tasklib/tests.py b/tasklib/tests.py index 72aebb9..4548df9 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -371,6 +371,21 @@ class TaskTest(TasklibTest): t['depends'] = set([dependency]) self.assertEqual(set(t._modified_fields), set()) + def test_setting_read_only_attrs_through_init(self): + # Test that we are unable to set readonly attrs through __init__ + for readonly_key in Task.read_only_fields: + kwargs = {'description': 'test task', readonly_key: 'value'} + self.assertRaises(RuntimeError, + lambda: Task(self.tw, **kwargs)) + + def test_setting_read_only_attrs_through_setitem(self): + # Test that we are unable to set readonly attrs through __init__ + for readonly_key in Task.read_only_fields: + t = Task(self.tw, description='test task') + self.assertRaises(RuntimeError, + lambda: t.__setitem__(readonly_key, 'value')) + + class AnnotationTest(TasklibTest): def setUp(self):