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))
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))
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))
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))
def test_tasks_empty_yields_empty(self): # when result = User.from_dict({'tasks': []}) # then self.assertIsInstance(result, User) self.assertEqual([], list(result.tasks))
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)
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)
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)
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)
def test_valid_email_gets_set(self): # when result = User.from_dict({'email': '*****@*****.**'}) # then self.assertIsInstance(result, User) self.assertEqual('*****@*****.**', result.email)
def test_email_none_is_ignored(self): # when result = User.from_dict({'email': None}) # then self.assertIsInstance(result, User) self.assertIsNone(result.email)
def test_valid_id_gets_set(self): # when result = User.from_dict({'id': 123}) # then self.assertIsInstance(result, User) self.assertEqual(123, result.id)
def test_id_none_is_ignored(self): # when result = User.from_dict({'id': None}) # then self.assertIsInstance(result, User) self.assertIsNone(result.id)