def test_unfollow(self): user = User(username="******", email="*****@*****.**") db.session.add(user) assert user.get_following().count() == 0 user2 = User(username="******", email="*****@*****.**") db.session.add(user2) assert user2.get_followers().count() == 0 db.session.commit() user.follow(user2) db.session.commit() assert user.get_following().count() == 1 assert user.get_following().first().id == user2.id assert user2.get_followers().count() == 1 assert user2.get_followers().first().id == user.id user.unfollow(user2) db.session.commit() assert user.get_following().count() == 0 assert user2.get_followers().count() == 0
def test_can_receive_mail(self): user = User(username="******", email="*****@*****.**") db.session.add(user) assert user.get_following().count() == 0 user2 = User(username="******", email="*****@*****.**") db.session.add(user2) db.session.commit() id1 = Identity(user.id) id2 = Identity(user2.id) id1.provides.update(user.provides) id2.provides.update(user2.provides) assert not user.permissions.send_message.allows(id2) assert not user2.permissions.send_message.allows(id1) user.follow(user2) db.session.commit() del user.permissions del user2.permissions assert not user.permissions.send_message.allows(id2) assert not user2.permissions.send_message.allows(id1) user2.follow(user) user.receive_email = True del user.permissions del user2.permissions assert user.permissions.send_message.allows(id2) assert not user2.permissions.send_message.allows(id1) user2.receive_email = True del user.permissions del user2.permissions assert user.permissions.send_message.allows(id2) assert user2.permissions.send_message.allows(id1) user.unfollow(user2) del user.permissions del user2.permissions assert not user.permissions.send_message.allows(id2) assert not user2.permissions.send_message.allows(id1)