Example #1
0
    def test_group_exclusion(self):
        people = list(RandrReminder(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_delivering_group()
        self.facility.save()
        people = list(RandrReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 0)

        self.facility.metadata['group'] = DeliveryGroups().current_processing_group()
        self.facility.save()
        people = list(RandrReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 0)
Example #2
0
    def test_reminder_set(self):
        now = datetime.utcnow()
        people = list(
            RandrReminder(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_delivering_group()
        self.facility.save()
        people = list(
            SupervisionReminder(TEST_DOMAIN, datetime.utcnow()).get_people())
        self.assertEqual(len(people), 1)

        update_statuses([self.facility.get_id],
                        SupplyPointStatusTypes.SUPERVISION_FACILITY,
                        SupplyPointStatusValues.REMINDER_SENT)

        people = list(SupervisionReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 0)

        SupplyPointStatus.objects.all().delete()

        people = list(SupervisionReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 1)

        SupplyPointStatus.objects.create(
            status_type=SupplyPointStatusTypes.SUPERVISION_FACILITY,
            status_value=SupplyPointStatusValues.RECEIVED,
            location_id=self.facility.get_id)
        people = list(SupervisionReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 0)
Example #3
0
    def test_randr_reminder_district(self):
        date = datetime(2015, 5, 1)
        RandrReminder(TEST_DOMAIN, date, 'DISTRICT').send()
        self.assertEqual(SMS.objects.count(), 1)

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

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

        now = datetime.utcnow()

        RandrReminder(TEST_DOMAIN, date, 'DISTRICT').send()
        self.assertEqual(SMS.objects.filter(date__gte=now).count(), 0)
Example #4
0
    def test_randr_reminder_facility(self):
        date = datetime(2015, 5, 1)
        RandrReminder(TEST_DOMAIN, date).send()
        self.assertEqual(SMS.objects.count(), 1)

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

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

        now = datetime.utcnow()

        RandrReminder(TEST_DOMAIN, date).send()
        self.assertEqual(SMS.objects.filter(date__gte=now).count(), 0)
Example #5
0
    def test_report_exclusion(self):
        now = datetime.utcnow()
        people = list(RandrReminder(TEST_DOMAIN, now).get_people())
        self.assertEqual(len(people), 1)

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

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

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