示例#1
0
    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
示例#2
0
    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
示例#3
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)
示例#4
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)