PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/web/test_web_task.py

https://bitbucket.org/prologic/circuits/
Python | 30 lines | 18 code | 10 blank | 2 comment | 0 complexity | 3a5750992c3a5c3e0e7b57f05860973a MD5 | raw file
 1#!/usr/bin/env python
 2
 3import os
 4
 5from circuits.web import Controller
 6from circuits import Event, Component
 7
 8from .helpers import urlopen
 9
10
11class Hello(Event):
12    """Hello Event"""
13
14class Root(Controller):
15
16    def index(self):
17        return self.fire(Hello(os.getpid()))
18
19class Task(Component):
20
21    def hello(self, pid):
22        return "Hello %d i'm %d" % (pid, os.getpid())
23
24def test(webapp):
25    t = Task()
26    t.start(link=webapp, process=True)
27    f = urlopen(webapp.server.base)
28    s = f.read()
29    assert s.decode() == "Hello %d i'm %d" % (os.getpid(), t._proc.pid)
30    t.stop()