def test_accept_duplicated_invite(self):
        user = create_logged_user(username='******')
        friend = create_user(last_name='test_accept_invite',
                             first_name='test_accept_invite',
                             username='******')

        friendship = create_friendship(user, friend)
        invite = create_invite(friend, user)

        self.http_client.fetch(
            self.get_url(
                '/invite/accept?username=%s&auth=should-be-user-auth' %
                friend.username), self.stop)

        response = self.wait()

        self.failIf(response.error)
        self.assertEqual(
            response.body,
            simplejson.dumps({
                "status":
                "error",
                "msg":
                "You and %s are already friend!" % friend.first_name
            }))

        invite.delete()
        friendship.delete()
        user.delete()
        friend.delete()
Example #2
0
    def test_remove_friendship(self):
        user = create_logged_user()
        user2 = create_user(last_name='test_remove_friendship-2', first_name='test_remove_friendship-2',  username='******')

        create_friendship(user, user2)

        self.http_client.fetch(self.get_url('/friendship/remove?username=%s&auth=should-be-user-auth' % user2.username), self.stop)

        response = self.wait()

        self.failIf(response.error)
        self.assertEqual(response.body, '{"status": "ok", "msg": "Your friendship has been removed!"}')
        friendship_db = self.session.query(Friendship).filter(Friendship.user_id == user.id).first()

        self.assertEqual(friendship_db, None)

        user.delete()
        user2.delete()
Example #3
0
    def test_get_friendship(self):
        user = create_logged_user()
        user2 = create_user(last_name='test_get_friendship-2', first_name='test_get_friendship-2',  username='******')
        user3 = create_user(last_name='test_get_friendship-3', first_name='test_get_friendship-3',  username='******')

        friendship = create_friendship(user, user2)
        friendship2 = create_friendship(user, user3)

        self.http_client.fetch(self.get_url('/friendship/get.json?auth=should-be-user-auth'), self.stop)

        response = self.wait()

        self.failIf(response.error)
        self.assertEqual(response.body, '{"friend": [{"username": "******", "first_name": "test_get_friendship-2", "last_name": "test_get_friendship-2", "gender": "M", "is_active": true, "is_superuser": false, "is_staff": false, "email": "should-be-email"}, {"username": "******", "first_name": "test_get_friendship-3", "last_name": "test_get_friendship-3", "gender": "M", "is_active": true, "is_superuser": false, "is_staff": false, "email": "should-be-email"}]}')

        friendship.delete()
        friendship2.delete()
        user3.delete()
        user2.delete()
        user.delete()
    def test_accept_duplicated_invite(self):
        user = create_logged_user(username='******')
        friend = create_user(last_name='test_accept_invite', first_name='test_accept_invite',  username='******')

        friendship = create_friendship(user, friend)
        invite = create_invite(friend, user)

        self.http_client.fetch(self.get_url('/invite/accept?username=%s&auth=should-be-user-auth' % friend.username), self.stop)

        response = self.wait()

        self.failIf(response.error)
        self.assertEqual(response.body, simplejson.dumps({"status": "error", "msg": "You and %s are already friend!" % friend.first_name}))

        invite.delete()
        friendship.delete()
        user.delete()
        friend.delete()