]> git.madduck.net Git - etc/taskwarrior.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Tests: Cover setting read only attributes
authorTomas Babej <tomasbabej@gmail.com>
Sat, 3 Jan 2015 11:16:49 +0000 (12:16 +0100)
committerTomas Babej <tomasbabej@gmail.com>
Sat, 3 Jan 2015 11:17:42 +0000 (12:17 +0100)
tasklib/tests.py

index 72aebb9f8ca875dbe2be8e4fc173f326c704b104..4548df93a6405903e869d65eb46601fe43fbf7ab 100644 (file)
@@ -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):