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,
     )
 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)
Example #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)
 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")
 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)
    def test_correct_value_used_for_previous_total(self):
        """
        Q2 snapshot's expenditure_from_previous_years_total updates total_spent of Q1 chart item.
        """
        snapshots_data = time_series_data([self.project_snapshot])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 1)
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 110)

        # Create Q2 Snapshot
        q2 = Quarter(number=2)
        irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year, quarter=q2)
        self.project_snapshot_2 = ProvInfraProjectSnapshot(
            irm_snapshot=irm_snapshot_2,
            project=self.project,
            actual_expenditure_q1=10,
            actual_expenditure_q2=20,
            expenditure_from_previous_years_total=200,
        )
        # Recreate the chart data
        snapshots_data = time_series_data(
            [self.project_snapshot, self.project_snapshot_2])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 2)

        # Check total_spent_to_date values for Q1 and Q2
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 210)
        self.assertEqual(snapshots_data[1]["total_spent_to_date"], 230)
    def test_q1_updated_after_q2_snapshot_inserted(self):
        """Test that Q1 values are updated correctly when Q2 snapshot is added"""
        snapshots_data = time_series_data([self.project_snapshot])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 1)

        # Check Q1 values
        self.assertEqual(snapshots_data[0]["total_spent_in_quarter"], 10)
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 210)

        # Create Q2 snapshot
        q2 = Quarter(number=2)
        irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year, quarter=q2)
        self.project_snapshot_2 = ProvInfraProjectSnapshot(
            irm_snapshot=irm_snapshot_2,
            project=self.project,
            actual_expenditure_q1=11,
            actual_expenditure_q2=20,
            expenditure_from_previous_years_total=200,
        )
        # Recreate the chart data
        snapshots_data = time_series_data(
            [self.project_snapshot, self.project_snapshot_2])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 2)

        # Check Q1 values
        self.assertEqual(snapshots_data[0]["total_spent_in_quarter"], 11)
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 211)
Example #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")
 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,
     )
 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",
     )
Example #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,
     )
Example #12
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,
     )
     q2 = Quarter(number=2)
     irm_snapshot_2 = IRMSnapshot(sphere=self.sphere, quarter=q2)
     self.project_snapshot_2 = InfraProjectSnapshot(
         irm_snapshot=irm_snapshot_2,
         project=self.project,
         actual_expenditure_q1=11,
         actual_expenditure_q2=20,
         expenditure_from_previous_years_total=200,
     )
 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",
     )
    def test_events_when_latest_snapshot_has_empty_dates(self):
        """Test that only not null values emitted to events"""
        q3 = Quarter(number=3)
        irm_snapshot_2 = IRMSnapshot(financial_year=self.fin_year, quarter=q3)
        self.project_snapshot_2 = ProvInfraProjectSnapshot(
            irm_snapshot=irm_snapshot_2,
            project=self.project,
            start_date="2029-09-30")
        events_data = time_series_data(
            [self.project_snapshot, self.project_snapshot_2])
        events_data = events_data[u"events"]
        self.assertEqual(len(events_data), 1)

        # Project Start Date
        self.assertEqual(events_data[0]["date"], "2029-09-30")
    def test_q1_q2_updated_after_q3_snapshot_inserted(self):
        """Test that Q1 and Q2 are updated correctly when Q3 inserted"""
        snapshots_data = time_series_data(
            [self.project_snapshot, self.project_snapshot_2])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 2)

        # Check Q1 values
        self.assertEqual(snapshots_data[0]["total_spent_in_quarter"], 11)
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 211)

        # Check Q2 values
        self.assertEqual(snapshots_data[1]["total_spent_in_quarter"], 20)
        self.assertEqual(snapshots_data[1]["total_spent_to_date"], 231)

        # Create Q3 snapshot
        q3 = Quarter(number=3)
        irm_snapshot_3 = IRMSnapshot(financial_year=self.fin_year, quarter=q3)
        self.project_snapshot_3 = ProvInfraProjectSnapshot(
            irm_snapshot=irm_snapshot_3,
            project=self.project,
            actual_expenditure_q1=12,
            actual_expenditure_q2=21,
            actual_expenditure_q3=30,
            expenditure_from_previous_years_total=200,
        )
        # Recreate the chart data
        snapshots_data = time_series_data([
            self.project_snapshot, self.project_snapshot_2,
            self.project_snapshot_3
        ])
        snapshots_data = snapshots_data[u"snapshots"]
        self.assertEqual(len(snapshots_data), 3)

        # Check Q1 values
        self.assertEqual(snapshots_data[0]["total_spent_in_quarter"], 12)
        self.assertEqual(snapshots_data[0]["total_spent_to_date"], 212)

        # Check Q2 values
        self.assertEqual(snapshots_data[1]["total_spent_in_quarter"], 21)
        self.assertEqual(snapshots_data[1]["total_spent_to_date"], 233)