Exemple #1
0
    def populate_daily_vehicle_data_register_reports(self):
        query = self.get_pending_submissions_by_class(DailyVehicleDataRegister)
        daily_vehicle_registers = query.all()

        for daily_vehicle_register in daily_vehicle_registers:
            daily_vehicle_register.status = Submission.APPROVED

        with transaction.manager:
            DBSession.add_all(daily_vehicle_registers)

        self.assertEqual(query.count(), 0)
Exemple #2
0
    def populate_compost_density(self):
        # Should be run before compost sales to make sure compost sales have a
        # density to reference

        # approve compost density records to have data to aggregate on
        query = self.get_pending_submissions_by_class(CompostDensityRegister)
        compost_densities = query.all()

        for compost_density in compost_densities:
            compost_density.status = Submission.APPROVED

        with transaction.manager:
            DBSession.add_all(compost_densities)

        # check that our number of un-approved compost densities
        self.assertEqual(query.count(), 0)

        return compost_densities
Exemple #3
0
    def setup_test_data(self):

        admin = User(id=1,
                     username='******',
                     password='******',
                     active=True,
                     group='nema')
        municipality = Municipality(name="Mukono")
        other_municipality = Municipality(name="Jinja")
        manager = User(id=2,
                       username='******',
                       password='******',
                       active=True,
                       group='sm',
                       municipality=municipality)
        other_manager = User(id=3,
                             username='******',
                             password='******',
                             active=True,
                             group='sm',
                             municipality=other_municipality)
        skip_a = Skip(municipality=municipality,
                      skip_type='A',
                      small_length=20,
                      large_length=30,
                      small_breadth=10,
                      large_breadth=16)
        skip_b = Skip(municipality=municipality,
                      skip_type='B',
                      small_length=20,
                      large_length=30,
                      small_breadth=10,
                      large_breadth=16)
        submission_handler_manager.clear()
        hook_submission_handlers()
        with transaction.manager:
            DBSession.add_all(
                [admin, manager, municipality, skip_a, skip_b, other_manager])
            for status, raw_json in self.submissions:
                json_payload = json.loads(raw_json)
                handler_class = submission_handler_manager.find_handler(
                    json_payload)
                handler_class().__call__(json_payload, status=status)
Exemple #4
0
    def populate_monthly_density_reports(self):
        # Should be run before daily wastes to make sure daily wastes have a
        # density to reference

        # approve monthly density records to have data to aggregate on
        query = self.get_pending_submissions_by_class(MonthlyDensity)
        monthly_densities = query.all()

        # change the monthly density threshold to
        MonthlyDensity.THRESHOLD_MIN = 3

        for monthly_density in monthly_densities:
            monthly_density.status = Submission.APPROVED

        with transaction.manager:
            DBSession.add_all(monthly_densities)

        # check that our number of approved monthly densities
        self.assertEqual(query.count(), 0)

        return monthly_densities