annual_spend property for requests model

This commit is contained in:
dandds 2018-08-20 10:25:06 -04:00
parent 260560699e
commit c88c763da2
2 changed files with 10 additions and 0 deletions

View File

@ -27,3 +27,8 @@ class Request(Base):
@property
def status_displayname(self):
return self.status_events[-1].displayname
@property
def annual_spend(self):
monthly = self.body.get("details_of_use", {}).get("estimated_monthly_spend", 0)
return monthly * 12

View File

@ -68,3 +68,8 @@ def test_request_status_pending_deleted_displayname():
request = Requests.set_status(request, RequestStatus.CANCELED)
assert request.status_displayname == "Canceled"
def test_annual_spend():
request = RequestFactory.create()
monthly = request.body.get("details_of_use").get("estimated_monthly_spend")
assert request.annual_spend == monthly * 12