Example #1
0
    def can_convert_to_dictionary(self):
        tmp_uuid = str(uuid.uuid4())
        tenant = Tenant(name=tmp_uuid, tenant_id=tmp_uuid)
        tenant_dict = tenant.as_dict()

        test_dict = Tenant.build_tenant_from_dict(tenant_dict).as_dict()
        expect(tenant_dict).to.equal(test_dict)
Example #2
0
    def on_post(self, req, resp, tenant_id):
        body = self.load_body(req)
        body['tenant_id'] = tenant_id

        tenant = Tenant.build_tenant_from_dict(body)
        Tenant.save_tenant(tenant)

        resp.status = falcon.HTTP_201
        resp.body = self.format_response_body({'tenant_id': tenant.id})
Example #3
0
    def on_post(self, req, resp, tenant_id):
        body = self.load_body(req)
        body['tenant_id'] = tenant_id

        tenant = Tenant.build_tenant_from_dict(body)
        Tenant.save_tenant(tenant)

        resp.status = falcon.HTTP_201
        resp.body = self.format_response_body({'tenant_id': tenant.id})
Example #4
0
    def on_put(self, req, resp, tenant_id):
        tenant = Tenant.get_tenant(tenant_id)
        if tenant:
            body = self.load_body(req)
            body['tenant_id'] = tenant_id

            tenant = Tenant.build_tenant_from_dict(body)
            Tenant.update_tenant(tenant)
        else:
            msg = 'Cannot find tenant: {tenant_id}'.format(tenant_id=tenant_id)
            resp.status = falcon.HTTP_404
            resp.body = json.dumps({'description': msg})
Example #5
0
    def on_put(self, req, resp, tenant_id):
        tenant = Tenant.get_tenant(tenant_id)
        if tenant:
            body = self.load_body(req)
            body['tenant_id'] = tenant_id

            tenant = Tenant.build_tenant_from_dict(body)
            Tenant.update_tenant(tenant)
        else:
            msg = 'Cannot find tenant: {tenant_id}'.format(tenant_id=tenant_id)
            resp.status = falcon.HTTP_404
            resp.body = json.dumps({'description': msg})
Example #6
0
 def on_get(self, req, resp, tenant_id):
     tenant = Tenant.get_tenant(tenant_id)
     if tenant:
         resp.body = self.format_response_body(tenant.as_dict())
     else:
         msg = 'Cannot find tenant: {tenant_id}'.format(tenant_id=tenant_id)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Example #7
0
 def on_get(self, req, resp, tenant_id):
     tenant = Tenant.get_tenant(tenant_id)
     if tenant:
         resp.body = self.format_response_body(tenant.as_dict())
     else:
         msg = 'Cannot find tenant: {tenant_id}'.format(tenant_id=tenant_id)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})