コード例 #1
0
 def test_tasks_non_empty_yields_same(self):
     # given
     task = Task('task')
     # when
     result = User.from_dict({'tasks': [task]})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual([task], list(result.tasks))
コード例 #2
0
 def test_any_lazy_overrides_all_non_lazy_properties(self):
     # given
     task = Task('task')
     # when
     result = User.from_dict({'tasks': [task]}, lazy={'x': 123})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual([], list(result.tasks))
コード例 #3
0
 def test_lazy_overrides_non_lazy_tasks(self):
     # given
     task = Task('task')
     task2 = Task('task2')
     # when
     result = User.from_dict({'tasks': [task]}, lazy={'tasks': [task2]})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual([task2], list(result.tasks))
コード例 #4
0
 def test_empty_yields_empty_dbuser(self):
     # when
     result = User.from_dict({})
     # then
     self.assertIsInstance(result, User)
     self.assertIsNone(result.id)
     self.assertIsNone(result.email)
     self.assertIsNone(result.hashed_password)
     self.assertFalse(result.is_admin)
     self.assertEqual([], list(result.tasks))
コード例 #5
0
 def test_tasks_empty_yields_empty(self):
     # when
     result = User.from_dict({'tasks': []})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual([], list(result.tasks))
コード例 #6
0
 def test_valid_is_admin_gets_set(self):
     # when
     result = User.from_dict({'is_admin': True})
     # then
     self.assertIsInstance(result, User)
     self.assertTrue(result.is_admin)
コード例 #7
0
 def test_is_admin_none_becomes_none(self):
     # when
     result = User.from_dict({'is_admin': None})
     # then
     self.assertIsInstance(result, User)
     self.assertIsNone(result.is_admin)
コード例 #8
0
 def test_valid_hashed_password_gets_set(self):
     # when
     result = User.from_dict({'hashed_password': '******'})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual('abc', result.hashed_password)
コード例 #9
0
 def test_hashed_password_none_becomes_none(self):
     # when
     result = User.from_dict({'hashed_password': None})
     # then
     self.assertIsInstance(result, User)
     self.assertIsNone(result.hashed_password)
コード例 #10
0
 def test_valid_email_gets_set(self):
     # when
     result = User.from_dict({'email': '*****@*****.**'})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual('*****@*****.**', result.email)
コード例 #11
0
 def test_email_none_is_ignored(self):
     # when
     result = User.from_dict({'email': None})
     # then
     self.assertIsInstance(result, User)
     self.assertIsNone(result.email)
コード例 #12
0
 def test_valid_id_gets_set(self):
     # when
     result = User.from_dict({'id': 123})
     # then
     self.assertIsInstance(result, User)
     self.assertEqual(123, result.id)
コード例 #13
0
 def test_id_none_is_ignored(self):
     # when
     result = User.from_dict({'id': None})
     # then
     self.assertIsInstance(result, User)
     self.assertIsNone(result.id)