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)
Beispiel #3
0
    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.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)