Ejemplo n.º 1
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year_1 = FinancialYear(slug="2018-19")
     q4 = Quarter(number=4)
     irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year_1,
                                  quarter=q4)
     self.project_snapshot = ProvInfraProjectSnapshot(
         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,
     )
     self.fin_year_2 = FinancialYear(slug="2019-20")
     q1 = Quarter(number=1)
     irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year_2,
                                  quarter=q1)
     self.project_snapshot_2 = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot_2,
         project=self.project,
         actual_expenditure_q1=50,
         expenditure_from_previous_years_total=200,
     )
Ejemplo n.º 2
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year_1 = FinancialYear(slug="2018-19")
     q2 = Quarter(number=2)
     irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year_1,
                                  quarter=q2)
     self.project_snapshot = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot_2, project=self.project)
     self.fin_year_2 = FinancialYear(slug="2019-20")
     q4 = Quarter(number=4)
     irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year_2,
                                  quarter=q4)
     self.project_snapshot_2 = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot_2, project=self.project)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year = FinancialYear(slug="2030-31")
     q2 = Quarter(number=2)
     irm_snapshot = IRMSnapshot(financial_year=self.fin_year, quarter=q2)
     self.project_snapshot = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot, project=self.project, status="Tender")
Ejemplo n.º 5
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year = FinancialYear(slug="2030-31")
     q4 = Quarter(number=4)
     irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year, quarter=q4)
     self.project_snapshot = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot_2, project=self.project)
Ejemplo n.º 6
0
 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())
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
 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")
Ejemplo n.º 9
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year = FinancialYear(slug="2030-31")
     q1 = Quarter(number=1)
     irm_snapshot = IRMSnapshot(financial_year=self.fin_year, quarter=q1)
     self.project_snapshot = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot,
         project=self.project,
         actual_expenditure_q1=10,
         expenditure_from_previous_years_total=100,
     )
Ejemplo n.º 10
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year = FinancialYear(slug="2019-20")
     q4 = Quarter(number=4)
     irm_snapshot = IRMSnapshot(financial_year=self.fin_year, quarter=q4)
     self.project_snapshot = ProvInfraProjectSnapshot(
         irm_snapshot=irm_snapshot,
         project=self.project,
         estimated_construction_start_date="2019-01-01",
         estimated_construction_end_date="2021-12-31",
     )
Ejemplo n.º 11
0
 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,
     )
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 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_1 = IRMSnapshot(sphere=self.sphere, quarter=q1)
     self.project_snapshot = InfraProjectSnapshot(
         irm_snapshot=irm_snapshot_1,
         project=self.project,
         actual_expenditure_q1=10,
         expenditure_from_previous_years_total=200,
     )
Ejemplo n.º 14
0
 def setUp(self):
     self.project = ProvInfraProject(IRM_project_id=1)
     self.fin_year = FinancialYear(slug="2030-31")
     q2 = Quarter(number=2)
     irm_snapshot = IRMSnapshot(financial_year=self.fin_year, quarter=q2)
     self.project_snapshot = ProvInfraProjectSnapshot(
         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",
     )
Ejemplo n.º 15
0
 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)