Updated tenant API and API testing

This commit is contained in:
jqxin2006 2013-03-06 07:14:26 -06:00
parent 1bf19a91f2
commit 06ad7b408b
3 changed files with 19 additions and 11 deletions

@ -33,16 +33,17 @@ def tenant(tenant_id):
tenant = Tenant(id=tenant_id)
db_session.add(tenant)
db_session.commit()
return Response("Tenant created!", status=201)
return jsonify(tenant.as_dict()), 201
else:
return Response("Tenant already exists!", status=200)
return Response(status=201)
return jsonify(tenant.as_dict())
else:
tenant = Tenant.query.filter_by(id=tenant_id).first()
if tenant is None:
return Response("No tenant found!", status=404)
else:
return Response("Tenant found!", status=200)
return jsonify(tenant.as_dict())
@api.route('/<int:tenant_id>/policies/', methods=['GET', 'POST'])
def policies(tenant_id):

@ -117,13 +117,13 @@ class BarbicanAPITesting:
test1 = BarbicanAPITesting()
print test1.get_tenant(123)
print test1.get_tenant(1234)
print test1.create_tenant(12345)
print test1.create_tenant(234)
print test1.add_agent(123)
test1.get_agents(123)
print test1.create_tenant(123456)
print test1.create_tenant(2349)
print test1.add_agent(1234)
test1.get_agents(1234)
print test1.add_policy("Before start up", 123)
print test1.get_policy(123)
print test1.add_policy("Before start up", 1234)
print test1.get_policy(1234)
print test1.add_log(123)
print test1.add_log(1234)
print test1.get_log(123)

@ -57,6 +57,13 @@ class Tenant(Base):
def __repr__(self):
return '<Tenant %s>' % self.uuid
def as_dict(self):
json = {
'id': self.id,
'uuid': self.uuid
}
return json
class Key(Base):