Ejemplo n.º 1
0
    def test_group_exclusion(self):
        people = list(DeliveryReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 1)
        self.assertEqual(people[0].get_id, self.user1.get_id)

        self.facility.metadata['group'] = DeliveryGroups().current_submitting_group()
        self.facility.save()
        people = list(DeliveryReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 0)

        self.facility.metadata['group'] = DeliveryGroups().current_processing_group()
        self.facility.save()
        people = list(DeliveryReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 0)
Ejemplo n.º 2
0
    def test_delivery_reminder_district(self):
        date = datetime(2015, 5, 1)
        DeliveryReminder(TEST_DOMAIN, date, 'DISTRICT').send()
        self.assertEqual(SMS.objects.count(), 1)

        statuses = SupplyPointStatus.objects.filter(status_type=SupplyPointStatusTypes.DELIVERY_DISTRICT)
        self.assertEqual(statuses.count(), 1)

        smses = SMS.objects.all()
        self.assertEqual(smses.first().text, six.text_type(DELIVERY_REMINDER_DISTRICT))
        self.assertEqual(
            statuses.values_list('location_id', flat=True)[0], self.district.get_id
        )

        now = datetime.utcnow()

        DeliveryReminder(TEST_DOMAIN, date, 'DISTRICT').send()
        self.assertEqual(SMS.objects.filter(date__gte=now).count(), 0)
Ejemplo n.º 3
0
    def test_delivery_reminder_facility(self):
        date = datetime(2015, 5, 1)
        DeliveryReminder(TEST_DOMAIN, date).send()
        self.assertEqual(SMS.objects.count(), 1)

        statuses = SupplyPointStatus.objects.filter(
            status_type=SupplyPointStatusTypes.DELIVERY_FACILITY)
        self.assertEqual(statuses.count(), 1)

        smses = SMS.objects.all()
        self.assertEqual(smses.first().text,
                         unicode(DELIVERY_REMINDER_FACILITY))
        self.assertEqual(
            statuses.values_list('location_id', flat=True)[0],
            self.facility2.get_id)

        now = datetime.utcnow()

        DeliveryReminder(TEST_DOMAIN, date).send()
        self.assertEqual(SMS.objects.filter(date__gte=now).count(), 0)
Ejemplo n.º 4
0
    def test_report_exclusion(self):
        now = datetime.utcnow()
        people = list(DeliveryReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 1)

        # reports for a different type shouldn't update status
        script = """
            5551234 > nimetuma
        """
        self.run_script(script)
        people = list(DeliveryReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 1)

        script = """
            5551234 > nimepokea
        """
        self.run_script(script)
        people = list(DeliveryReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 0)

        people = list(DeliveryReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 1)