def test_send_friend_request(self): db = User() r = FriendRequest() db.init_data_base(self.engine) db.register_user("ben", "123", self.engine) db.register_user("alex", "123", self.engine) f1 = db.login_user("ben", "123", self.engine) f2 = db.login_user("alex", "123", self.engine) waiting = r.check_waiting_request(f1, self.engine) self.assertEqual(len(waiting), 0) self.assertTrue(r.send_friend_request(f2, 'ben', self.engine)) waiting = r.check_waiting_request(f1, self.engine) self.assertEqual(len(waiting), 1) self.assertTrue(r.denial_request(f1, 'alex', self.engine)) waiting = r.check_waiting_request(f1, self.engine) self.assertEqual(len(waiting), 0) self.assertTrue(r.send_friend_request(f2, 'ben', self.engine)) self.assertTrue(r.confirm_request(f1, 'alex', self.engine)) self.assertEqual(len(waiting), 0)
def setUp(self): self.engine = create_engine('sqlite:///:memory:') db = User() db.init_data_base(self.engine)