class UserTest(TestCase): def setUp(self): self.pop = Populator() self.pop.run() def tearDown(self): self.pop.clear() def test_save(self): self.users = [User(), User(), User()] for index, user in enumerate(self.users): user.firstName = "User_" + str(index) user.lastName = "User_" + str(index) + "_lastName" user.userName = "******" + str(index) user.passHash = user.userName for user in self.users: self.assertIsNone(user.id, "The user id for a new user should be None") user.save() self.assertIsNotNone( user.id, "After a save the user id should have a generated id") for user in self.users: if user.id is not None: user.delete()
class UserTest(TestCase): def setUp(self): self.pop = Populator() self.pop.run() def tearDown(self): self.pop.clear() def test_save(self): self.users = [User(), User(), User()] for index, user in enumerate(self.users): user.firstName = "User_"+str(index) user.lastName = "User_"+str(index)+"_lastName" user.userName = "******"+str(index) user.passHash = user.userName for user in self.users: self.assertIsNone(user.id, "The user id for a new user should be None") user.save() self.assertIsNotNone(user.id, "After a save the user id should have a generated id") for user in self.users: if user.id is not None: user.delete()
class MessageTest(TestCase): def setUp(self): self.pop = Populator() self.pop.run() self.message = Message() self.users = User.objects def tearDown(self): if self.message.id is not None: self.message.delete() self.pop.clear() def test_save(self): self.message.subject = "First message" self.message.text = "This is the first message ever in the system" self.message.receiver = self.users[1] self.message.sender = self.users[0] self.assertIsNone(self.message.id) self.message.save() self.assertIsNotNone(self.message.id)
def setUp(self): self.pop = Populator() self.pop.run() self.message = Message() self.users = User.objects
def setUp(self): self.pop = Populator() self.pop.run()