Esempio n. 1
0
    def test_location_created_after_facility_processing(self):
        start_date = datetime(2015, 9, 1)
        end_date = datetime.utcnow()
        with mock.patch('custom.ilsgateway.tanzania.warehouse.updater.default_start_date', return_value=start_date), \
                mock.patch('custom.ilsgateway.tasks.default_start_date', return_value=start_date), \
                mock.patch('custom.ilsgateway.tasks.get_start_date', return_value=start_date):
            run = ReportRun.objects.create(start=start_date,
                                           end=end_date,
                                           start_run=datetime.utcnow(),
                                           domain=self.domain.name)

            process_facility_warehouse_data(self.facility1, start_date,
                                            end_date, run)

            facility = make_loc(code='new_facility',
                                name='New Facility',
                                domain=self.domain.name,
                                type='FACILITY',
                                parent=self.district1,
                                metadata={'group': 'A'})

            process_non_facility_warehouse_data(self.district1, start_date,
                                                end_date, run)
            self.assertEqual(
                OrganizationSummary.objects.filter(
                    date__lte=datetime(2015, 9, 3)).count(), 2)

            facility.delete()
Esempio n. 2
0
def recalculate_on_group_change(location, last_run):
    OrganizationSummary.objects.filter(location_id=location.get_id).delete()
    process_facility_warehouse_data(location, default_start_date(), last_run.end)

    for parent in location.sql_location.get_ancestors(ascending=True):
        process_non_facility_warehouse_data(parent.couch_location,
                                            default_start_date(), last_run.end, strict=False)
Esempio n. 3
0
def recalculate_on_group_change(location, last_run):
    OrganizationSummary.objects.filter(location_id=location.get_id).delete()
    process_facility_warehouse_data(location, default_start_date(),
                                    last_run.end)
    return {
        ancestor.location_type.name: {ancestor}
        for ancestor in location.sql_location.get_ancestors(ascending=True)
    }
Esempio n. 4
0
    def test_location_created_after_facility_processing(self):
        start_date = datetime(2015, 9, 1)
        end_date = datetime.utcnow()
        with mock.patch('custom.ilsgateway.tanzania.warehouse.updater.default_start_date', return_value=start_date), \
                mock.patch('custom.ilsgateway.tasks.default_start_date', return_value=start_date), \
                mock.patch('custom.ilsgateway.tasks.get_start_date', return_value=start_date):
            run = ReportRun.objects.create(start=start_date, end=end_date,
                                           start_run=datetime.utcnow(), domain=self.domain.name)

            process_facility_warehouse_data(self.facility1, start_date, end_date, run)

            facility = make_loc(code='new_facility', name='New Facility', domain=self.domain.name,
                                type='FACILITY', parent=self.district1, metadata={'group': 'A'})

            process_non_facility_warehouse_data(self.district1, start_date, end_date, run)
            self.assertEqual(OrganizationSummary.objects.filter(date__lte=datetime(2015, 9, 3)).count(), 2)

            facility.delete()
Esempio n. 5
0
def recalculate_on_group_change(location, last_run):
    OrganizationSummary.objects.filter(location_id=location.get_id).delete()
    process_facility_warehouse_data(location, default_start_date(), last_run.end)
    return {
        ancestor.location_type.name: {ancestor} for ancestor in location.sql_location.get_ancestors(ascending=True)
    }