Tests on analysis and compensation
* enhances tests for analysis and compensation app
This commit is contained in:
parent
b854695399
commit
1047a5f119
@ -57,6 +57,10 @@ class TimeSpanReportTestCase(BaseTestCase):
|
||||
self.oek_old.legal.save()
|
||||
self.oek_old.responsible.save()
|
||||
|
||||
self.deduction.account = self.eco_account
|
||||
self.deduction.intervention = self.eiv
|
||||
self.deduction.save()
|
||||
|
||||
def test_init(self):
|
||||
date_from = now().date() - timedelta(days=365)
|
||||
date_to = now().date()
|
||||
|
@ -244,6 +244,7 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.client_user.post(record_url, post_data)
|
||||
|
||||
# Check that the intervention is still not recorded
|
||||
self.intervention.refresh_from_db()
|
||||
self.assertIsNone(self.intervention.recorded)
|
||||
|
||||
# Now fill out the data for a compensation
|
||||
|
@ -106,14 +106,17 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
"surface": test_deductable_surface,
|
||||
"conservation_office": test_conservation_office.id
|
||||
}
|
||||
self.client_user.post(url, post_data)
|
||||
response = self.client_user.post(url, post_data)
|
||||
self.assertEqual(response.status_code, 302, msg=f"{response.content.decode('utf-8')}")
|
||||
self.eco_account.refresh_from_db()
|
||||
|
||||
deductions_surface = self.eco_account.get_deductions_surface()
|
||||
|
||||
check_on_elements = {
|
||||
self.eco_account.title: new_title,
|
||||
self.eco_account.identifier: new_identifier,
|
||||
self.eco_account.deductable_surface: test_deductable_surface,
|
||||
self.eco_account.deductable_rest: test_deductable_surface,
|
||||
self.eco_account.deductable_rest: test_deductable_surface - deductions_surface,
|
||||
self.eco_account.comment: new_comment,
|
||||
}
|
||||
|
||||
@ -223,7 +226,9 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.eco_account.refresh_from_db()
|
||||
self.assertEqual(1, self.eco_account.deductions.count())
|
||||
self.assertEqual(1, self.intervention.deductions.count())
|
||||
deduction = self.eco_account.deductions.first()
|
||||
deduction = self.eco_account.deductions.get(
|
||||
surface=test_surface
|
||||
)
|
||||
self.assertEqual(deduction.surface, test_surface)
|
||||
self.assertEqual(self.eco_account.deductable_rest, self.eco_account.deductable_surface - deduction.surface)
|
||||
self.assertEqual(deduction.account, self.eco_account)
|
||||
|
@ -400,12 +400,13 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.eco_account.share_with_user_list([self.superuser])
|
||||
self.eco_account.save()
|
||||
num_all_deducs = EcoAccountDeduction.objects.count()
|
||||
num_acc_deducs = self.eco_account.deductions.count()
|
||||
|
||||
# Run the request
|
||||
self.client_user.post(new_url, post_data)
|
||||
|
||||
# Expect the deduction to be created, since all constraints are fulfilled
|
||||
self.assertEqual(1, self.eco_account.deductions.count())
|
||||
self.assertEqual(num_acc_deducs + 1, self.eco_account.deductions.count())
|
||||
self.assertEqual(num_all_deducs + 1, EcoAccountDeduction.objects.count())
|
||||
|
||||
# Make sure the deduction contains the expected data
|
||||
|
@ -65,7 +65,7 @@ class BaseTestCase(TestCase):
|
||||
self.compensation = self.create_dummy_compensation()
|
||||
self.eco_account = self.create_dummy_eco_account()
|
||||
self.ema = self.create_dummy_ema()
|
||||
self.deduction = self.create_dummy_deduction(acc=self.eco_account, interv=self.intervention)
|
||||
self.deduction = self.create_dummy_deduction()
|
||||
self.create_dummy_states()
|
||||
self.create_dummy_action()
|
||||
self.codes = self.create_dummy_codes()
|
||||
|
Loading…
Reference in New Issue
Block a user