Exemplo n.º 1
0
 def test_valid_task_id_is_ignored(self):
     # given
     task = Task('task')
     # when
     result = Note.from_dict({'task_id': task.id})
     # then
     self.assertIsInstance(result, Note)
     self.assertIsNone(result.task_id)
Exemplo n.º 2
0
 def test_valid_task_gets_set(self):
     # given
     task = Task('task')
     # when
     result = Note.from_dict({'task': task})
     # then
     self.assertIsInstance(result, Note)
     self.assertIs(task, result.task)
Exemplo n.º 3
0
 def test_empty_yields_empty_dbnote(self):
     # when
     result = Note.from_dict({})
     # then
     self.assertIsInstance(result, Note)
     self.assertIsNone(result.id)
     self.assertIsNone(result.content)
     self.assertIsNone(result.timestamp)
     self.assertIsNone(result.task)
Exemplo n.º 4
0
 def test_lazy_overrides_non_lazy_task(self):
     # given
     task = Task('task')
     task2 = Task('task2')
     # when
     result = Note.from_dict({'task': task}, lazy={'task': lambda: task2})
     # then
     self.assertIsInstance(result, Note)
     self.assertIs(task2, result.task)
Exemplo n.º 5
0
 def test_task_id_none_is_ignored(self):
     # when
     result = Note.from_dict({'task_id': None})
     # then
     self.assertIsInstance(result, Note)
     self.assertIsNone(result.task_id)
Exemplo n.º 6
0
 def test_valid_timestamp_gets_set(self):
     # when
     result = Note.from_dict({'timestamp': datetime(2017, 1, 1)})
     # then
     self.assertIsInstance(result, Note)
     self.assertEqual(datetime(2017, 1, 1), result.timestamp)
Exemplo n.º 7
0
 def test_timestamp_none_becomes_none(self):
     # when
     result = Note.from_dict({'timestamp': None})
     # then
     self.assertIsInstance(result, Note)
     self.assertIsNone(result.timestamp)
Exemplo n.º 8
0
 def test_valid_content_gets_set(self):
     # when
     result = Note.from_dict({'content': 'abc'})
     # then
     self.assertIsInstance(result, Note)
     self.assertEqual('abc', result.content)
Exemplo n.º 9
0
 def test_content_none_is_ignored(self):
     # when
     result = Note.from_dict({'content': None})
     # then
     self.assertIsInstance(result, Note)
     self.assertIsNone(result.content)
Exemplo n.º 10
0
 def test_valid_id_gets_set(self):
     # when
     result = Note.from_dict({'id': 123})
     # then
     self.assertIsInstance(result, Note)
     self.assertEqual(123, result.id)