Merge pull request #687 from dod-ccpo/demo-data

Demo data
This commit is contained in:
leigh-mil
2019-03-01 16:25:51 -05:00
committed by GitHub
6 changed files with 162 additions and 166 deletions

View File

@@ -163,7 +163,7 @@ class MockReportingProvider(ReportingInterface):
"FM_Prod": {FIXTURE_MONTHS[0]: 5686},
}
CUMULATIVE_BUDGET_AARDVARK = {
CUMULATIVE_BUDGET_A_WING = {
FIXTURE_MONTHS[7]: {"spend": 9857, "cumulative": 9857},
FIXTURE_MONTHS[6]: {"spend": 7881, "cumulative": 17738},
FIXTURE_MONTHS[5]: {"spend": 14010, "cumulative": 31748},
@@ -174,14 +174,14 @@ class MockReportingProvider(ReportingInterface):
FIXTURE_MONTHS[0]: {"spend": 36028, "cumulative": 241_831},
}
CUMULATIVE_BUDGET_BELUGA = {
CUMULATIVE_BUDGET_B_WING = {
FIXTURE_MONTHS[1]: {"spend": 4838, "cumulative": 4838},
FIXTURE_MONTHS[0]: {"spend": 14500, "cumulative": 19338},
}
REPORT_FIXTURE_MAP = {
"Aardvark": {
"cumulative": CUMULATIVE_BUDGET_AARDVARK,
"A-Wing": {
"cumulative": CUMULATIVE_BUDGET_A_WING,
"applications": [
MockApplication("LC04", ["Integ", "PreProd", "Prod"]),
MockApplication("SF18", ["Integ", "PreProd", "Prod"]),
@@ -201,8 +201,8 @@ class MockReportingProvider(ReportingInterface):
],
"budget": 500_000,
},
"Beluga": {
"cumulative": CUMULATIVE_BUDGET_BELUGA,
"B-Wing": {
"cumulative": CUMULATIVE_BUDGET_B_WING,
"applications": [
MockApplication("NP02", ["Integ", "PreProd", "Prod"]),
MockApplication("FM", ["Integ", "Prod"]),

View File

@@ -19,6 +19,11 @@ from werkzeug.datastructures import FileStorage
from atst.models import Attachment, Base, types, mixins
# Imports used for mocking TO balance
from atst.domain.csp.reports import MockReportingProvider
from flask import current_app as app
import random
class Status(Enum):
STARTED = "Started"
@@ -135,6 +140,10 @@ class TaskOrder(Base, mixins.TimestampsMixin):
def is_active(self):
return self.status == Status.ACTIVE
@property
def is_expired(self):
return self.status == Status.EXPIRED
@property
def status(self):
if self.is_submitted:
@@ -164,6 +173,15 @@ class TaskOrder(Base, mixins.TimestampsMixin):
@property
def balance(self):
# Faking the remaining balance using the stubbed reporting data for A-Wing & B-Wing
if (
self.portfolio_name in MockReportingProvider.REPORT_FIXTURE_MAP
and self.is_active
):
return self.budget - app.csp.reports.get_total_spending(self.portfolio)
# Faking an almost fully spent TO if the TO is expired
if self.is_expired:
return random.randrange(300) / 100 # nosec
# TODO: somehow calculate the remaining balance. For now, assume $0 spent
return self.budget