1. Alexander Shorin
  2. hydra

Source

hydra / apps / all_docs / shows / tests.py

def show_doc(doc, req):
    http = require('lib/http')
    content = require('lib/content')['provider']()
    if req['id']:
        return http['400']('accessing by document id is not supported', req)

    couchtests = require('lib/tests/runner')['init']()
    targets = content.decode('json', req['query'].get('targets', '[]'))
    couchtests.run(*targets)
    doc = {'results': couchtests.results(req['query'].get('status')),
           'stats': couchtests.stats()}

    def json():
        return content.make_response_body('json', doc)
    def yaml():
        return content.make_response_body('yaml', doc)
    def xmlrpc():
        return content.make_response_body('xmlrpc', doc)
    def ubjson():
        return content.make_response_body('ubjson', doc)
    def html():
        templates = require('lib/templates')
        return content.make_response_body('html', doc, req,
                                          templates['tests/index'])

    register_type('xmlrpc', 'application/xml+rpc')
    register_type('ubjson', 'application/x-ubjson')
    provides('json', json)
    provides('yaml', yaml)
    provides('xmlrpc', xmlrpc)
    provides('ubjson', ubjson)
    provides('html', html)