def setUp(self): self.client.force_login(self.test_user) self.test_year = 2019 self.test_period = 9 self.file_mock = MagicMock(spec=File) self.file_mock.name = 'test.txt' self.cost_centre_code = TEST_COST_CENTRE self.cost_centre_code_1 = 888888 self.valid_natural_account_code = TEST_VALID_NATURAL_ACCOUNT_CODE self.not_valid_natural_account_code = TEST_NOT_VALID_NATURAL_ACCOUNT_CODE self.programme_code = TEST_PROGRAMME_CODE self.test_amount = 100 self.directorate_obj = DirectorateFactory.create( directorate_code="T123") CostCentreFactory.create(cost_centre_code=self.cost_centre_code, directorate=self.directorate_obj) CostCentreFactory.create(cost_centre_code=self.cost_centre_code_1, directorate=self.directorate_obj) NaturalCodeFactory.create( natural_account_code=self.valid_natural_account_code, used_for_budget=True) NaturalCodeFactory.create( natural_account_code=self.not_valid_natural_account_code) ProgrammeCodeFactory.create(programme_code=self.programme_code) ProgrammeCodeFactory.create(programme_code="333333") self.year_obj = FinancialYear.objects.get(financial_year=2019)
def setUp(self): self.client.force_login(self.test_user) self.test_year = 2019 self.test_period = 9 self.cost_centre_code = "109189" self.natural_account_code = 52191003 self.programme_code = "310940" self.project_code = "0123" self.analisys1 = "00798" self.analisys2 = "00321" self.test_amount = 100 self.directorate_obj = DirectorateFactory.create( directorate_code="T123") CostCentreFactory.create(cost_centre_code=self.cost_centre_code, directorate=self.directorate_obj) NaturalCodeFactory.create( natural_account_code=self.natural_account_code, economic_budget_code="CAPITAL", ) ProgrammeCodeFactory.create(programme_code=self.programme_code) ProjectCodeFactory.create(project_code=self.project_code) Analysis1Factory.create(analysis1_code=self.analisys1) Analysis2Factory.create(analysis2_code=self.analisys2) self.year_obj = FinancialYear.objects.get(financial_year=2019) self.year_obj.current = True self.year_obj.save
def test_data_returned_in_response(self): self.current_code = "123456" ProgrammeCodeFactory.create(programme_code=self.current_code) self.archived_code = HistoricalProgrammeCodeFactory.create( financial_year_id=2019).programme_code self.url_name = "data_lake_programme_code" self.row_lenght = 4 self.code_position = 0 self.check_data()
def setUp(self): self.nac_code = 999999 self.cost_centre_code = 888812 self.analysis_1_code = "1111111" self.analysis_2_code = "2222222" self.project_code = "3000" self.programme = ProgrammeCodeFactory.create() self.cost_centre = NaturalCodeFactory.create( natural_account_code=self.nac_code, ) self.project = ProjectCodeFactory.create( project_code=self.project_code, ) CostCentreFactory.create(cost_centre_code=self.cost_centre_code) self.analysis_1 = Analysis1Factory.create( analysis1_code=self.analysis_1_code, ) self.analysis_2 = Analysis2Factory.create( analysis2_code=self.analysis_2_code, )
def setUp(self): self.client.force_login(self.test_user) self.test_year = 2019 make_financial_year_current(self.test_year) self.test_period = 9 self.cost_centre_code = TEST_COST_CENTRE self.valid_natural_account_code = TEST_VALID_NATURAL_ACCOUNT_CODE self.not_valid_natural_account_code = TEST_NOT_VALID_NATURAL_ACCOUNT_CODE self.programme_code = TEST_PROGRAMME_CODE self.test_amount = 100 self.directorate_obj = DirectorateFactory.create( directorate_code='T123') CostCentreFactory.create( cost_centre_code=self.cost_centre_code, directorate=self.directorate_obj, active=False, ) NaturalCodeFactory.create( natural_account_code=self.valid_natural_account_code, economic_budget_code=VALID_ECONOMIC_CODE_LIST[0], active=False, ) NaturalCodeFactory.create( natural_account_code=18162001, economic_budget_code=VALID_ECONOMIC_CODE_LIST[0], active=False, ) NaturalCodeFactory.create( natural_account_code=self.not_valid_natural_account_code, active=False, ) ProgrammeCodeFactory.create( programme_code=self.programme_code, active=False, ) ProgrammeCodeFactory.create(programme_code='310540') ProgrammeCodeFactory.create(programme_code='310530') self.period_obj = FinancialPeriod.objects.get( period_calendar_code=self.test_period) self.year_obj = FinancialYear.objects.get(financial_year=2019) dummy_upload = FileUpload( s3_document_file='dummy.csv', uploading_user=self.test_user, document_type=FileUpload.ACTUALS, ) dummy_upload.save() self.check_financial_code = CheckFinancialCode(dummy_upload)
def set_up_test_objects(context): # Clear forecast data cache cache.clear() nac_codes = [111111, 999999] analysis_1_code = "1111111" analysis_2_code = "2222222" project_code_value = "3000" financial_year = FinancialYear.objects.first() if not financial_year: FinancialYearFactory() if BudgetType.objects.count() == 0: BudgetType.objects.create( budget_type_key="DEL", budget_type="Programme DEL", ) BudgetType.objects.create( budget_type_key="AME", budget_type="Programme AME", ) BudgetType.objects.create( budget_type_key="ADMIN", budget_type="Admin", ) CostCentreFactory.create(cost_centre_code=TEST_COST_CENTRE_CODE, ) programme = ProgrammeCodeFactory.create() project_code = ProjectCodeFactory.create(project_code=project_code_value) analysis_1 = Analysis1Factory.create(analysis1_code=analysis_1_code) analysis_2 = Analysis2Factory.create(analysis2_code=analysis_2_code) for nac_code in nac_codes: nac_code = NaturalCodeFactory.create(natural_account_code=nac_code, ) for financial_period in range(1, 14): financial_month = financial_period + 3 if financial_month > 12: financial_month = financial_month - 12 month_name = (financial_period, datetime.date(get_current_financial_year(), financial_month, 1).strftime('%B'))[1] financial_period_count = FinancialPeriod.objects.filter( financial_period_code=financial_period).count() if financial_period_count == 0: FinancialPeriodFactory(financial_period_code=financial_period, period_long_name=month_name, period_short_name=month_name[0:3], period_calendar_code=financial_month) financial_code = FinancialCode.objects.filter( cost_centre_id=TEST_COST_CENTRE_CODE, programme=programme, natural_account_code=nac_code, analysis1_code=analysis_1, analysis2_code=analysis_2, project_code=project_code, ).first() if not financial_code: financial_code = FinancialCode.objects.create( cost_centre_id=TEST_COST_CENTRE_CODE, programme=programme, natural_account_code=nac_code, analysis1_code=analysis_1, analysis2_code=analysis_2, project_code=project_code, ) ForecastMonthlyFigure.objects.create( financial_year_id=get_current_financial_year(), financial_period_id=financial_period, financial_code=financial_code, amount=0, ) if ForecastEditState.objects.count() == 0: ForecastEditStateFactory.create()