def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year_1 = FinancialYear(slug="2018-19") self.sphere_1 = Sphere(financial_year=fin_year_1, name="Provincial") q4 = Quarter(number=4) irm_snapshot_2 = IRMSnapshot(sphere=self.sphere_1, quarter=q4) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot_2, project=self.project, actual_expenditure_q1=1, actual_expenditure_q2=2, actual_expenditure_q3=3, actual_expenditure_q4=4, expenditure_from_previous_years_total=100, ) fin_year_2 = FinancialYear(slug="2019-20") self.sphere_2 = Sphere(financial_year=fin_year_2, name="Provincial") q1 = Quarter(number=1) irm_snapshot_2 = IRMSnapshot(sphere=self.sphere_2, quarter=q1) self.project_snapshot_2 = InfraProjectSnapshot( irm_snapshot=irm_snapshot_2, project=self.project, actual_expenditure_q1=50, expenditure_from_previous_years_total=200, )
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year_1 = FinancialYear(slug="2018-19") self.sphere_1 = Sphere(financial_year=fin_year_1, name="Provincial") q2 = Quarter(number=2) irm_snapshot_2 = IRMSnapshot(sphere=self.sphere_1, quarter=q2) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot_2, project=self.project) fin_year_2 = FinancialYear(slug="2019-20") self.sphere_2 = Sphere(financial_year=fin_year_2, name="Provincial") q4 = Quarter(number=4) irm_snapshot_2 = IRMSnapshot(sphere=self.sphere_2, quarter=q4) self.project_snapshot_2 = InfraProjectSnapshot( irm_snapshot=irm_snapshot_2, project=self.project)
def setUp(self): year = FinancialYear(slug="2030-31") sphere = Sphere(financial_year=year, name="A sphere") government = Government(sphere=sphere, name="A government") self.department = Department( government=government, name="Fake", vote_number=1, is_vote_primary=True, intro="", ) mock_dataset = Mock() mock_openspending_api = Mock() self.mock_openspending_api = mock_openspending_api mock_openspending_api.get_adjustment_kind_ref = Mock mock_openspending_api.get_phase_ref = Mock mock_openspending_api.get_programme_name_ref = Mock mock_openspending_api.get_department_name_ref = Mock(return_value='department_name_ref') mock_openspending_api.get_financial_year_ref = Mock(return_value="financial_year_ref") mock_openspending_api.aggregate = Mock mock_openspending_api.filter_dept = Mock(return_value={'cells': []}) mock_openspending_api.filter_by_ref_exclusion = Mock mock_openspending_api.aggregate_by_refs = Mock mock_openspending_api.aggregate_url = Mock mock_dataset.get_openspending_api = Mock(return_value=mock_openspending_api) self.department.get_adjusted_estimates_expenditure_dataset = Mock(return_value=mock_dataset) self.department.get_financial_year = Mock(return_value=year) self.department._get_adjustments_by_econ_class = Mock(return_value=Mock()) self.department._get_adjustments_by_programme = Mock(return_value=Mock()) self.department._get_adjustments_by_type = Mock(return_value=Mock()) self.department._get_budget_virements = Mock(return_value=Mock()) self.department._get_budget_special_appropriations = Mock(return_value=Mock()) self.department._get_budget_direct_charges = Mock(return_value=Mock()) models.csv_url = Mock(return_value=Mock())
def setUp(self): self.mock_data = DEPARTMENT_MOCK_DATA year = FinancialYear(slug="2018-19") sphere = Sphere(financial_year=year, name="A sphere") government = Government(sphere=sphere, name="A government") self.department = Department( government=government, name="Fake", vote_number=1, is_vote_primary=True, intro="", ) self.mock_openspending_api = Mock() self.mock_openspending_api.get_adjustment_kind_ref = Mock(return_value='adjustment_kind_ref') self.mock_openspending_api.get_phase_ref = Mock(return_value='budget_phase.budget_phase') self.mock_openspending_api.get_geo_ref = Mock(return_value='government.government') self.mock_openspending_api.get_programme_name_ref = Mock self.mock_openspending_api.get_department_name_ref = Mock(return_value='department_name_ref') self.mock_openspending_api.get_financial_year_ref = Mock(return_value="financial_year.financial_year") self.mock_openspending_api.aggregate = Mock(return_value={'cells': [{'value.sum': 1, '_count': 0}]}) self.mock_openspending_api.filter_dept = Mock(return_value={'cells': []}) self.mock_openspending_api.filter_by_ref_exclusion = Mock self.mock_openspending_api.aggregate_url = Mock self.mock_dataset = Mock() self.mock_dataset.get_openspending_api = Mock(return_value=self.mock_openspending_api) dataset_patch = patch('budgetportal.datasets.Dataset.get_latest_cpi_resource', return_value=('2018-19', '5b315ff0-55e9-4ba8-b88c-2d70093bfe9d')) dataset_patch.start() self.addCleanup(dataset_patch.stop)
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year = FinancialYear(slug="2030-31") self.sphere = Sphere(financial_year=fin_year, name="Provincial") q2 = Quarter(number=2) irm_snapshot_2 = IRMSnapshot(sphere=self.sphere, quarter=q2) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot_2, project=self.project, status="Tender")
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year = FinancialYear(slug="2030-31") self.sphere = Sphere(financial_year=fin_year, name="Provincial") q2 = Quarter(number=2) irm_snapshot = IRMSnapshot(sphere=self.sphere, quarter=q2) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot, project=self.project, estimated_total_project_cost=100, )
def setUp(self): self.year = FinancialYear.objects.create(slug="2019-20") self.year.save() national = Sphere(financial_year=self.year, name="national") national.save() provincial = Sphere(financial_year=self.year, name="provincial") provincial.save() southafrica = Government(sphere=national, name="South Africa") southafrica.save() province = Government(sphere=provincial, name="Test Province 1") province.save() Department( government=southafrica, name="TP1 National Test Dept 2", vote_number=1, is_vote_primary=True, intro="", ).save() Department( government=province, name="TP1 Provincial Test Dept 2", vote_number=1, is_vote_primary=True, intro="", ).save() self.mock_dataset = Mock() self.mock_openspending_api = Mock() self.mock_openspending_api.get_geo_ref = Mock( return_value='geo_source.government') self.mock_openspending_api.get_function_ref = Mock( return_value='function_group.function_group') self.mock_openspending_api.get_year_ref = Mock( return_value='function_group.function_group') self.mock_openspending_api.get_financial_year_ref = Mock( return_value="financial_year.financial_year") self.mock_openspending_api.get_department_name_ref = Mock( return_value="vote_number.department") self.mock_openspending_api.get_subprogramme_name_ref = Mock( return_value="subprogramme.subprogramme") self.mock_dataset.get_openspending_api = Mock( return_value=self.mock_openspending_api) def mock_get_focus_area_data(__, sphere): if sphere == "provincial": cells = FOCUS_AREA_PROVINCIAL_MOCK_DATA elif sphere == "national": cells = FOCUS_AREA_NATIONAL_MOCK_DATA return cells, self.mock_openspending_api self.mock_get_focus_area_data = mock_get_focus_area_data
def setUp(self): year = FinancialYear(slug="2030-31") sphere = Sphere(financial_year=year, name="A sphere") government = Government(sphere=sphere, name="A government") self.department = Department( government=government, name="Fake", vote_number=1, is_vote_primary=True, intro="", ) self.department.get_adjusted_estimates_expenditure_dataset = Mock(return_value=None)
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year = FinancialYear(slug="2030-31") self.sphere = Sphere(financial_year=fin_year, name="Provincial") q1 = Quarter(number=1) irm_snapshot = IRMSnapshot(sphere=self.sphere, quarter=q1) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot, project=self.project, actual_expenditure_q1=10, expenditure_from_previous_years_total=100, )
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year = FinancialYear(slug="2019-20") self.sphere = Sphere(financial_year=fin_year, name="Provincial") q4 = Quarter(number=4) irm_snapshot = IRMSnapshot(sphere=self.sphere, quarter=q4) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot, project=self.project, estimated_construction_start_date="2019-01-01", estimated_construction_end_date="2021-12-31", )
def setUp(self): self.project = InfraProject(IRM_project_id=1) fin_year = FinancialYear(slug="2030-31") self.sphere = Sphere(financial_year=fin_year, name="Provincial") q2 = Quarter(number=2) irm_snapshot = IRMSnapshot(sphere=self.sphere, quarter=q2) self.project_snapshot = InfraProjectSnapshot( irm_snapshot=irm_snapshot, project=self.project, start_date="2029-09-30", estimated_construction_start_date="2030-01-01", estimated_completion_date="2033-02-01", contracted_construction_end_date="2033-01-31", estimated_construction_end_date="2032-12-31", )
def setUp(self): self.mock_data = DEPARTMENT_MOCK_DATA year = FinancialYear(slug="2018-19") sphere = Sphere(financial_year=year, name="A sphere") government = Government(sphere=sphere, name="A government") self.department = Department( government=government, name="Fake", vote_number=1, is_vote_primary=True, intro="", ) self.mock_openspending_api = Mock() self.mock_openspending_api.get_adjustment_kind_ref = Mock( return_value="adjustment_kind_ref") self.mock_openspending_api.get_phase_ref = Mock( return_value="budget_phase.budget_phase") self.mock_openspending_api.get_geo_ref = Mock( return_value="government.government") self.mock_openspending_api.get_programme_name_ref = Mock( return_value="programme_number.programme") self.mock_openspending_api.get_department_name_ref = Mock( return_value="department_name_ref") self.mock_openspending_api.get_financial_year_ref = Mock( return_value="financial_year.financial_year") self.mock_openspending_api.aggregate = Mock( return_value={"cells": [{ "value.sum": 1, "_count": 0 }]}) self.mock_openspending_api.filter_dept = Mock( return_value={ "cells": self.mock_data["program_test_cells_complete"] }) self.mock_openspending_api.aggregate_url = Mock self.mock_dataset = Mock() self.mock_dataset.get_openspending_api = Mock( return_value=self.mock_openspending_api)