def test_get_quarterly_numbers(tas_balances_data): """Test the function that generates quarterly tas balances.""" # retrieve all quarterly numbers and test results quarters = AppropriationAccountBalances.get_quarterly_numbers() # number of quarterly adjusted records should = number of records # in AppropriationAccountBalances assert len(list(quarters)) == 2 # submission 1: has no previous subission # submission 2: its previous submission is submission 1 sub1 = SubmissionAttributes.objects.get(previous_submission__isnull=True) sub2 = SubmissionAttributes.objects.get(previous_submission__isnull=False) for q in quarters: if q.submission == sub1: # qtrly values for year's first submission should remain unchanged assert q.budget_authority_appropriated_amount_cpe == Decimal('10.00') assert q.unobligated_balance_cpe == Decimal('99.99') else: # qtrly values for year's 2nd submission should be equal to 2nd # submission values - first submission values assert q.budget_authority_appropriated_amount_cpe == Decimal('0.00') assert q.unobligated_balance_cpe == Decimal('.01') # test getting quarterly results for a specific submission quarters = AppropriationAccountBalances.get_quarterly_numbers( sub2.submission_id) # number of quarterly adjusted records should = number of records # in AppropriationAccountBalances assert len(list(quarters)) == 1 # requesting data for non-existent submission returns zero records quarters = AppropriationAccountBalances.get_quarterly_numbers(-888) assert len(list(quarters)) == 0
def test_get_quarterly_numbers(tas_balances_data): """Test the function that generates quarterly tas balances.""" # retrieve all quarterly numbers and test results quarters = AppropriationAccountBalances.get_quarterly_numbers() # number of quarterly adjusted records should = number of records # in AppropriationAccountBalances assert len(list(quarters)) == 2 # submission 1: has no previous subission # submission 2: its previous submission is submission 1 sub1 = SubmissionAttributes.objects.get(previous_submission__isnull=True) sub2 = SubmissionAttributes.objects.get(previous_submission__isnull=False) for q in quarters: if q.submission == sub1: # qtrly values for year's first submission should remain unchanged assert q.budget_authority_appropriated_amount_cpe == Decimal( "10.00") assert q.unobligated_balance_cpe == Decimal("99.99") else: # qtrly values for year's 2nd submission should be equal to 2nd # submission values - first submission values assert q.budget_authority_appropriated_amount_cpe == Decimal( "0.00") assert q.unobligated_balance_cpe == Decimal(".01") # test getting quarterly results for a specific submission quarters = AppropriationAccountBalances.get_quarterly_numbers( sub2.submission_id) # number of quarterly adjusted records should = number of records # in AppropriationAccountBalances assert len(list(quarters)) == 1 # requesting data for non-existent submission returns zero records quarters = AppropriationAccountBalances.get_quarterly_numbers(-888) assert len(list(quarters)) == 0
def test_get_quarterly_null_previous_submission(tas_balances_data): """ Test case when a field value is not in the current submission but was null in the previous submission. """ sub1 = SubmissionAttributes.objects.get(previous_submission__isnull=True) quarters = AppropriationAccountBalances.get_quarterly_numbers() for q in quarters: if q.submission == sub1: # qtrly values for year's first submission should remain unchanged # (null values become 0 due to COALESCE) assert q.budget_authority_unobligated_balance_brought_forward_fyb == Decimal('0.0') else: # if the equivalent value in the first submisison is NULL, quarterly # numbers should equal the number on the 2nd submission assert q.budget_authority_unobligated_balance_brought_forward_fyb == Decimal('6.99')
def test_get_quarterly_null_previous_submission(tas_balances_data): """ Test case when a field value is not in the current submission but was null in the previous submission. """ sub1 = SubmissionAttributes.objects.get(previous_submission__isnull=True) quarters = AppropriationAccountBalances.get_quarterly_numbers() for q in quarters: if q.submission == sub1: # qtrly values for year's first submission should remain unchanged # (null values become 0 due to COALESCE) assert q.budget_authority_unobligated_balance_brought_forward_fyb == Decimal( "0.0") else: # if the equivalent value in the first submisison is NULL, quarterly # numbers should equal the number on the 2nd submission assert q.budget_authority_unobligated_balance_brought_forward_fyb == Decimal( "6.99")