1. Sylvain Hellegouarch
  2. CherryPy Recipes

Source

CherryPy Recipes / testing / load / funkload_ / test_blog.py

# -*- coding: utf-8 -*-
import random
import time

from funkload.Lipsum import Lipsum
from funkload.FunkLoadTestCase import FunkLoadTestCase

class Blog(FunkLoadTestCase):
    def test_access(self):
        server_url = self.conf_get('main', 'url')
        self.get(server_url + '/', description='Blog home page access')

    def test_comment(self):
        server_url = self.conf_get('main', 'url')
        self.get(server_url, description='Blog home page access')

        post_id = random.randint(1, 12)
        ret = self.post(server_url + "/post/comment/%d" % post_id,
                        params=[['author', 'virtual author'],
                                ['text', Lipsum().getParagraph()]],
                        description="Commenting")
        self.assert_(ret.code == 200, "Failed to comment")

        self.get(server_url, description='Blog home page access after commenting')