Example #1
0
 def test_valid_task_id_is_ignored(self):
     # given
     task = Task('task')
     # when
     result = Attachment.from_dict({'task_id': task.id})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIsNone(result.task_id)
Example #2
0
 def test_valid_task_gets_set(self):
     # given
     task = Task('task')
     # when
     result = Attachment.from_dict({'task': task})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIs(task, result.task)
Example #3
0
 def test_lazy_overrides_non_lazy_task(self):
     # given
     task = Task('task')
     task2 = Task('task2')
     # when
     result = Attachment.from_dict({'task': task},
                                   lazy={'task': lambda: task2})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIs(task2, result.task)
Example #4
0
 def test_empty_yields_empty_dbattachment(self):
     # when
     result = Attachment.from_dict({})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIsNone(result.id)
     self.assertIsNone(result.path)
     self.assertIsNone(result.description)
     self.assertIsNone(result.timestamp)
     self.assertIsNone(result.filename)
     self.assertIsNone(result.task)
Example #5
0
 def test_task_none_is_ignored(self):
     # when
     result = Attachment.from_dict({'task': None})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIsNone(result.task)
Example #6
0
 def test_valid_filename_gets_set(self):
     # when
     result = Attachment.from_dict({'filename': 'abc'})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertEqual('abc', result.filename)
Example #7
0
 def test_valid_timestamp_gets_set(self):
     # when
     result = Attachment.from_dict({'timestamp': datetime(2017, 1, 1)})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertEqual(datetime(2017, 1, 1), result.timestamp)
Example #8
0
 def test_timestamp_none_becomes_none(self):
     # when
     result = Attachment.from_dict({'timestamp': None})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIsNone(result.timestamp)
Example #9
0
 def test_valid_description_gets_set(self):
     # when
     result = Attachment.from_dict({'description': 'abc'})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertEqual('abc', result.description)
Example #10
0
 def test_description_none_is_ignored(self):
     # when
     result = Attachment.from_dict({'description': None})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertIsNone(result.description)
Example #11
0
 def test_valid_id_gets_set(self):
     # when
     result = Attachment.from_dict({'id': 123})
     # then
     self.assertEqual(result.object_type, ObjectTypes.Attachment)
     self.assertEqual(123, result.id)