Beispiel #1
0
    def _initialize_client(self):
        # Initialize the cabochon client.

        # We don't want this in __init__, to avoid depending on a
        # specific zcml load order: we need an IProvideSiteConfig
        # utility to be set up by now, and if we did this in __init__,
        # that would have to happen before this package's zcml could
        # load, because it creates a global CabochonUtility instance.

        cabochon_client = CabochonClient(self.cabochon_messages_dir, self.cabochon_uri, self.username, self.password)
        # initialize and start the thread
        sender = cabochon_client.sender()
        thread = Thread(target=sender.send_forever)
        thread.setDaemon(True)
        thread.start()
        return cabochon_client
        else:
            status = '200 OK'
            start_response(status, [('Content-type', 'text/plain')])
            return ['{"status" : "accepted"}']

message_dir = tempfile.mkdtemp()
        
test_server = CabochonTestServer()
test_server.start()

cabochon_url = "http://localhost:10424/"

good_event_url = cabochon_url + "good/handle/1"
bad_event_url = cabochon_url + "error/fleem"

client = CabochonClient(message_dir, cabochon_url)
sender = client.sender()

def setup():
    t = Thread(target=sender.send_forever)
    t.setDaemon(True)
    t.start()
    
def teardown():
    sender.stop()
    for f in os.listdir(message_dir):
        os.remove(os.path.join(message_dir, f))

    os.rmdir(message_dir)
    
def test_message():