fix sales order code to pass the tests again
This commit is contained in:
parent
68fc1e8418
commit
cea0e75b70
10
api/web.py
10
api/web.py
@ -244,15 +244,13 @@ def run_sales_order_generation():
|
||||
tenants = flask.request.json.get("tenants", None)
|
||||
tenant_query = session.query(Tenant)
|
||||
|
||||
if tenants is not None:
|
||||
try:
|
||||
if isinstance(tenants, list):
|
||||
tenant_query = tenant_query.filter(Tenant.id.in_(tenants))
|
||||
if tenant_query.count() == 0:
|
||||
# if an explicit list of tenants is passed, and none of them
|
||||
# exist in the db, then we consider that an error.
|
||||
return 400, {"errors": ["No tenants found from given list."]}
|
||||
except TypeError:
|
||||
# TODO: make an invalid parameters helper function
|
||||
return 400, {"invalid parameters": {"tenants": "Must be a list."}}
|
||||
else:
|
||||
elif tenants is not None:
|
||||
return 400, {"missing parameters": {"tenants": "A list of tenant ids."}}
|
||||
|
||||
# Handled like this for a later move to Celery distributed workers
|
||||
|
@ -60,7 +60,9 @@ class TestApi(test_interface.TestInterface):
|
||||
now = datetime.now().\
|
||||
replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
helpers.fill_db(self.session, 7, 5, now)
|
||||
resp = self.app.post("/sales_order")
|
||||
resp = self.app.post("/sales_order",
|
||||
params=json.dumps({}),
|
||||
content_type='application/json')
|
||||
resp_json = json.loads(resp.body)
|
||||
|
||||
self.assertEquals(resp.status_int, 200)
|
||||
|
Loading…
x
Reference in New Issue
Block a user