Exemple #1
0
    def on_put(self, req, resp):
        params = json.load(req.stream)
        if not params or not params.get('name'):
            raise falcon.HTTPBadRequest(config.HTTP_400, 'invalid params')

        token = uuid.uuid4().hex
        name = params.get('name')

        try:
            site = create(token, name)
        except Exception:
            logger.exception('create')
            raise falcon.HTTPInternalServerError(config.HTTP_500, 'create site failed')

        resp.status = falcon.HTTP_201
        resp.stream = ijson.dump({'token': site.token})
Exemple #2
0
def setup():
    import tests
    import config
    for k in dir(config):
        value = getattr(tests, k, None)
        if not value:
            continue
        setattr(config, k, value)

    from models.site import Site, Block
    from query.site import create
    Site.create_table(fail_silently=True)
    Block.create_table(fail_silently=True)
    global site
    from tests.base import TEST_TOKEN
    site = create(TEST_TOKEN, 'test')