Exemplo n.º 1
0
    def testMessageInitiatorLossedAdjustments(self):
        translation.activate("sw")
        contact = register_user(
            self,
            "32000",
            "Trainer",
        )
        contact = register_user(self, "32347", "Person 1", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32348", "Person 2", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32349", "Person 3", "d31049",
                                "CHIDEDE DISP")

        script = """
            32000 > test la d31049
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.LOSS_ADJUST_HELP)
        }
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D31049")
        sps = SupplyPointStatus.objects.filter(
            supply_point=sp, status_type="la_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT,
                         sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.LOSS_ADJUSTMENT_FACILITY,
                         sps.status_type)
Exemplo n.º 2
0
    def testMessageInitiatorLateDeliveryReportDistrict(self):
        translation.activate("sw")

        register_user(
            self,
            "32000",
            "Trainer",
        )

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        for contact_id in ["+255714774041", "+255714774042", "+255714774043"]:
            register_user(self, contact_id, "Person %s" % contact_id, "d10101",
                          "TANDAHIMBA")

        script = """
            32000 > test latedelivery d10101
            32000 < %(test_handler_confirm)s
            +255714774041 < %(response)s
            +255714774042 < %(response)s
            +255714774043 < %(response)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.DELIVERY_LATE_DISTRICT) % {
                "group_name": "changeme",
                "group_total": 1,
                "not_responded_count": 2,
                "not_received_count": 3
            }
        }
        self.runScript(script)
Exemplo n.º 3
0
    def testRandRSubmittedDistrictWithAmounts(self):
        contact = register_user(self, "22345", "District Person")
        contact2 = register_user(self, "22346", "MSD Person")

        # submitted successfully
        translation.activate("sw")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        contact.supply_point = sp
        contact.save()

        role = ContactRole.objects.get(code__iexact=config.Roles.MSD)
        contact2.role = role
        contact2.supply_point = None
        contact2.save()

        script = """
          22345 > nimetuma a 10 b 11 c 12
          22345 < %(submitted_message)s
          22346 < %(submitted_notification_msd)s
        """ % {'submitted_message': _(config.Messages.SUBMITTED_CONFIRM) %
                                         {"contact_name": contact.name,
                                          "sdp_name": sp.name},
               'submitted_notification_msd': _(config.Messages.SUBMITTED_NOTIFICATION_MSD) % {"district_name":"TANDAHIMBA",
                                                                                           "group_a": 10,
                                                                                           "group_b": 11,
                                                                                           "group_c": 12}}
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="rr_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.SUBMITTED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.R_AND_R_DISTRICT, sps.status_type)
Exemplo n.º 4
0
    def testDeliveryDistrictReceived(self):
        #Should record a SupplyPointStatus and send out a notification to all the District's sub-facilities.

        # district contact
        self.contact = register_user(self, "778", "someone")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        self.contact.supply_point = sp
        self.contact.save()

        #facility contacts
        contact = register_user(self, "32346", "Person 1", "d30701", "CHAUME DISP")
        contact = register_user(self, "32347", "Person 2", "d31049", "CHIDEDE DISP")

                # submitted successfully
        translation.activate("sw")

        script = """
          778 > nimepokea
          778 < %(submitted_message)s
          32346 < %(delivery_confirm_children)s
          32347 < %(delivery_confirm_children)s
        """ % {"submitted_message":         _(config.Messages.DELIVERY_CONFIRM_DISTRICT) %
                                                {"contact_name":  "someone",
                                                "facility_name":  "TANDAHIMBA"},
               "delivery_confirm_children": _(config.Messages.DELIVERY_CONFIRM_CHILDREN) %
                                                {"district_name": sp.name} }
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="del_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.RECEIVED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_DISTRICT, sps.status_type)
Exemplo n.º 5
0
    def testMessageInitiatorForward(self):
        translation.activate("sw")
        contact = register_user(
            self,
            "32000",
            "Trainer",
        )
        contact = register_user(self, "32347", "Person 1", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32348", "Person 2", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32349", "Person 3", "d31049",
                                "CHIDEDE DISP")

        script = """
            32000 > test fw D31049 %(test_message)s
            32000 < %(test_handler_confirm)s
            32347 < %(test_message)s
            32348 < %(test_message)s
            32349 < %(test_message)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "test_message": "this is a test message"
        }
        self.runScript(script)
Exemplo n.º 6
0
    def testMessageInitiatorDeliveryDistrict(self):
        translation.activate("sw")

        contact = register_user(self, "32000", "Trainer", )

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        for contact_id in ["+255714774041","+255714774042","+255714774043"]:
            register_user(self, contact_id, "Person %s" % contact_id, "d10101", "TANDAHIMBA")

        script = """
            32000 > test delivery d10101
            32000 < %(test_handler_confirm)s
            +255714774041 < %(response)s
            +255714774042 < %(response)s
            +255714774043 < %(response)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "response":_(config.Messages.DELIVERY_REMINDER_DISTRICT)}
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="del_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_DISTRICT, sps.status_type)
Exemplo n.º 7
0
    def testRandRSubmittedDistrictWithAmounts(self):
        contact = register_user(self, "22345", "District Person")
        contact2 = register_user(self, "22346", "MSD Person")

        # submitted successfully
        translation.activate("sw")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        contact.supply_point = sp
        contact.save()

        role = ContactRole.objects.get(code__iexact=config.Roles.MSD)
        contact2.role = role
        contact2.supply_point = None
        contact2.save()

        script = """
          22345 > nimetuma a 10 b 11 c 12
          22345 < %(submitted_message)s
          22346 < %(submitted_notification_msd)s
        """ % {
            "submitted_message": _(config.Messages.SUBMITTED_CONFIRM)
            % {"contact_name": contact.name, "sdp_name": sp.name},
            "submitted_notification_msd": _(config.Messages.SUBMITTED_NOTIFICATION_MSD)
            % {"district_name": "TANDAHIMBA", "group_a": 10, "group_b": 11, "group_c": 12},
        }
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(supply_point=sp, status_type="rr_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.SUBMITTED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.R_AND_R_DISTRICT, sps.status_type)
Exemplo n.º 8
0
    def testMessageInitiatorStockInquiryIndividualLocation(self):
        raise Exception("This feature hasn't been implemented yet")
        translation.activate("sw")
        contact = register_user(
            self,
            "32000",
            "Trainer",
        )
        contact = register_user(self, "32347", "Person 1", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32348", "Person 2", "d31049",
                                "CHIDEDE DISP")
        contact = register_user(self, "32349", "Person 3", "d31049",
                                "CHIDEDE DISP")

        p = Product.objects.get(sms_code__iexact="id")
        p.product_code = 'm11111'
        p.save()

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        translation.activate("sw")

        print p.name
        print p.product_code

        script = """
            32000 > test si d31049 m11112
            32000 < %(invalid_code_message)s 
            32000 > test si d31049 m11111
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            32000 > test si d10101 m11111
            32000 < %(location_error)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.STOCK_INQUIRY_MESSAGE) % {
                "product_name": p.name,
                "msd_code": p.product_code
            },
            "invalid_code_message": _(config.Messages.INVALID_PRODUCT_CODE) % {
                "product_code": "m11112"
            },
            "location_error":
            _(config.Messages.STOCK_INQUIRY_NOT_A_FACILITY_ERROR) % {
                "location_name": "changeme",
                "location_type": "changeme"
            }
        }
        self.runScript(script)
Exemplo n.º 9
0
    def testMessageInitiatorSOHFacility(self):
        translation.activate("sw")
        register_user(self, "32000", "Trainer", )
        register_user(self, "32347", "Person 1", "d31049", "CHIDEDE DISP")
        register_user(self, "32348", "Person 2", "d31049", "CHIDEDE DISP")
        register_user(self, "32349", "Person 3", "d31049", "CHIDEDE DISP")

        script = """
            32000 > test soh d31049
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            32000 > test hmk d31049
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "response":_(config.Messages.SOH_HELP_MESSAGE)}
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D31049")
        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="soh_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.SOH_FACILITY, sps.status_type)
Exemplo n.º 10
0
    def testMessageInitiatorSupervisionFacility(self):
        translation.activate("sw")
        register_user(
            self,
            "32000",
            "Trainer",
        )
        register_user(self, "32347", "Person 1", "d31049", "CHIDEDE DISP")
        register_user(self, "32348", "Person 2", "d31049", "CHIDEDE DISP")
        register_user(self, "32349", "Person 3", "d31049", "CHIDEDE DISP")

        script = """
            32000 > test supervision d31049
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.SUPERVISION_REMINDER)
        }
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D31049")
        sps = SupplyPointStatus.objects.filter(
            supply_point=sp,
            status_type="super_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT,
                         sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.SUPERVISION_FACILITY,
                         sps.status_type)
Exemplo n.º 11
0
    def testMessageInitiatorDeliveryFacility(self):
        translation.activate("sw")
        register_user(
            self,
            "+255714700000",
            "Trainer",
        )
        register_user(self, "+255714700001", "Person 1", "d31049",
                      "CHIDEDE DISP")
        register_user(self, "+255714700002", "Person 2", "d31049",
                      "CHIDEDE DISP")
        register_user(self, "+255714700003", "Person 3", "d31049",
                      "CHIDEDE DISP")

        script = """
            +255714700000 > test delivery d31049
            +255714700000 < %(test_handler_confirm)s
            +255714700001 < %(response)s
            +255714700002 < %(response)s
            +255714700003 < %(response)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.DELIVERY_REMINDER_FACILITY)
        }
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D31049")
        sps = SupplyPointStatus.objects.filter(
            supply_point=sp, status_type="del_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT,
                         sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_FACILITY,
                         sps.status_type)
Exemplo n.º 12
0
    def testMessageInitiatorForward(self):
        translation.activate("sw")
        contact = register_user(self, "32000", "Trainer", )
        contact = register_user(self, "32347", "Person 1", "d31049", "CHIDEDE DISP")
        contact = register_user(self, "32348", "Person 2", "d31049", "CHIDEDE DISP")
        contact = register_user(self, "32349", "Person 3", "d31049", "CHIDEDE DISP")

        script = """
            32000 > test fw D31049 %(test_message)s
            32000 < %(test_handler_confirm)s
            32347 < %(test_message)s
            32348 < %(test_message)s
            32349 < %(test_message)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "test_message":"this is a test message"}
        self.runScript(script)
Exemplo n.º 13
0
 def testStockOnHand(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone")
     add_products(contact, ["id", "dp", "ip"])
     
     script = """
         778 > Hmk Id 400 Dp 569 Ip 678
         778 < %(soh_confirm)s
     """ % {"soh_confirm": _(config.Messages.SOH_CONFIRM)}
     self.runScript(script)
     self.assertEqual(3, ProductReport.objects.count())
     self.assertEqual(3, ProductStock.objects.count())
     
     # check created statuses
     self.assertEqual(2, SupplyPointStatus.objects.count())
     soh_status = SupplyPointStatus.objects.get(status_type=SupplyPointStatusTypes.SOH_FACILITY)
     self.assertEqual(contact.supply_point, soh_status.supply_point)
     self.assertEqual(SupplyPointStatusValues.SUBMITTED, soh_status.status_value)
     la_status = SupplyPointStatus.objects.get(status_type=SupplyPointStatusTypes.LOSS_ADJUSTMENT_FACILITY)
     self.assertEqual(contact.supply_point, la_status.supply_point)
     self.assertEqual(SupplyPointStatusValues.REMINDER_SENT, la_status.status_value)
     
     for ps in ProductStock.objects.all():
         self.assertEqual(contact.supply_point, ps.supply_point)
         self.assertTrue(0 != ps.quantity)
Exemplo n.º 14
0
    def testStockout(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone")
        add_products(contact, ["id", "dp", "ip"])
        script = """
            778 > Hmk Id 400 Dp 569 Ip 678
            778 < %(soh_confirm)s
            """ % {
            "soh_confirm": _(config.Messages.SOH_CONFIRM)
        }
        self.runScript(script)

        self.assertEqual(3, ProductStock.objects.count())
        for ps in ProductStock.objects.all():
            self.assertEqual(contact.supply_point, ps.supply_point)
            self.assertTrue(0 != ps.quantity)

        script = """
            778 > stockout id dp ip
            """ % {
            "stockout_confirm": _(config.Messages.STOCKOUT_CONFIRM) % {
                "contact_name": "changeme",
                "product_names": "changeme",
                "facility_name": "changeme"
            }
        }
        self.runScript(script)
        for ps in ProductStock.objects.all():
            self.assertEqual(contact.supply_point, ps.supply_point)
            self.assertEqual(0, ps.quantity)
Exemplo n.º 15
0
    def testStockInquiry(self):

        contact = register_user(self, "778", "someone")
        add_products(contact, ["id"])
        p = Product.objects.get(sms_code__iexact="id")
        p.product_code = 'm11111'
        p.save()

        translation.activate("sw")

        script = """
            778 > si m11111 100
            778 < %(stock_inquiry_confirm)s
        """ % {
            "stock_inquiry_confirm":
            _(config.Messages.STOCK_INQUIRY_CONFIRM) % {
                "quantity": "100",
                "product_name": p.name
            }
        }
        self.runScript(script)

        self.assertEqual(1, ProductStock.objects.count())
        for ps in ProductStock.objects.all():
            self.assertEqual(contact.supply_point, ps.supply_point)
            self.assertEqual(100, ps.quantity)
Exemplo n.º 16
0
    def testDeliveryDistrictNotReceived(self):
        contact = register_user(self, "32345", "RandR Tester")

        # submitted successfully
        translation.activate("sw")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        contact.supply_point = sp
        contact.save()

        script = """
          32345 > sijapokea
          32345 < %(submitted_message)s
        """ % {
            'submitted_message': _(config.Messages.NOT_DELIVERED_CONFIRM)
        }
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(
            supply_point=sp,
            status_type="del_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.NOT_RECEIVED,
                         sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_DISTRICT,
                         sps.status_type)
Exemplo n.º 17
0
    def testStockOnHand(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone")
        add_products(contact, ["id", "dp", "ip"])

        script = """
            778 > Hmk Id 400 Dp 569 Ip 678
            778 < %(soh_confirm)s
        """ % {
            "soh_confirm": _(config.Messages.SOH_CONFIRM)
        }
        self.runScript(script)
        self.assertEqual(3, ProductReport.objects.count())
        self.assertEqual(3, ProductStock.objects.count())

        # check created statuses
        self.assertEqual(2, SupplyPointStatus.objects.count())
        soh_status = SupplyPointStatus.objects.get(
            status_type=SupplyPointStatusTypes.SOH_FACILITY)
        self.assertEqual(contact.supply_point, soh_status.supply_point)
        self.assertEqual(SupplyPointStatusValues.SUBMITTED,
                         soh_status.status_value)
        la_status = SupplyPointStatus.objects.get(
            status_type=SupplyPointStatusTypes.LOSS_ADJUSTMENT_FACILITY)
        self.assertEqual(contact.supply_point, la_status.supply_point)
        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT,
                         la_status.status_value)

        for ps in ProductStock.objects.all():
            self.assertEqual(contact.supply_point, ps.supply_point)
            self.assertTrue(0 != ps.quantity)
Exemplo n.º 18
0
 def testYes(self):
     contact = register_user(self, "778", "someone")
     script = """
       778 > ndio
       778 < Kama umetuma R&R fomu yako jibu 'nimetuma', kama umepokea vifaa jibu 'nimepokea'
     """
     self.runScript(script)
Exemplo n.º 19
0
 def testYes(self):
     contact = register_user(self, "778", "someone")
     script = """
       778 > ndio
       778 < Kama umetuma R&R fomu yako jibu 'nimetuma', kama umepokea vifaa jibu 'nimepokea'
     """
     self.runScript(script)
Exemplo n.º 20
0
    def testLossesAdjustmentsLAKeyword(self):
        translation.activate("sw")

        contact = register_user(self, "778", "someone")
        add_products(contact, ["id", "dp", "ip"])

        script = """
            778 > Hmk Id 400 Dp 569 Ip 678
            778 < %(soh_confirm)s
        """ % {"soh_confirm": _(config.Messages.SOH_CONFIRM)}
        self.runScript(script)

        self.assertEqual(3, ProductStock.objects.count())
        for ps in ProductStock.objects.all():
            self.assertEqual(contact.supply_point, ps.supply_point)
            self.assertTrue(0 != ps.quantity)

        script = """
            778 > la id -3 dp -5 ip 13
            778 < %(loss_adjust_confirm)s
        """ % {"loss_adjust_confirm": _(config.Messages.LOSS_ADJUST_CONFIRM)}
        self.runScript(script)

        self.assertEqual(397, ProductStock.objects.get(product__sms_code="id").quantity)
        self.assertEqual(564, ProductStock.objects.get(product__sms_code="dp").quantity)
        self.assertEqual(691, ProductStock.objects.get(product__sms_code="ip").quantity)
Exemplo n.º 21
0
 def setUp(self):
     super(TestSOHThankYou, self).setUp()
     Contact.objects.all().delete()
     self.contact = register_user(self, "778", "someone")
     sp = self.contact.supply_point
     sp.groups = (SupplyPointGroup.objects.get\
                  (code=DeliveryGroups().current_submitting_group()),)
     sp.save()
Exemplo n.º 22
0
 def setUp(self):
     super(TestSOHThankYou, self).setUp()
     Contact.objects.all().delete()
     self.contact = register_user(self, "778", "someone")
     sp = self.contact.supply_point
     sp.groups = (SupplyPointGroup.objects.get\
                  (code=DeliveryGroups().current_submitting_group()),)
     sp.save()
Exemplo n.º 23
0
    def testMessageInitiatorHelp(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")

        script = """
            778 > test
            778 < %(test_help)s
            """ % {"test_help": _(config.Messages.TEST_HANDLER_HELP)}
        self.runScript(script)
Exemplo n.º 24
0
    def testMessageInitiatorBadCode(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")

        script = """
            778 > test la d5000000
            778 < %(test_bad_code)s
            """ % {"test_bad_code": _(config.Messages.TEST_HANDLER_BAD_CODE) % {"code":"d5000000"}}
        self.runScript(script)
Exemplo n.º 25
0
 def setUp(self):
     super(TestDeliveryReminder, self).setUp()
     Contact.objects.all().delete()
     ProductReport.objects.all().delete()
     self.contact = register_user(self, "778", "someone")
     sp = self.contact.supply_point
     sp.groups = (SupplyPointGroup.objects.get\
                  (code=DeliveryGroups().current_delivering_group()),)
     sp.save()
Exemplo n.º 26
0
 def setUp(self):
     super(TestDeliveryReminder, self).setUp()
     Contact.objects.all().delete()
     ProductReport.objects.all().delete()
     self.contact = register_user(self, "778", "someone")
     sp = self.contact.supply_point
     sp.groups = (SupplyPointGroup.objects.get\
                  (code=DeliveryGroups().current_delivering_group()),)
     sp.save()
Exemplo n.º 27
0
    def testHelpRegistered(self):
        translation.activate("sw")
        
        # Registered user
        contact = register_user(self, "778", "someone")
        script = """
          778 > msaada
          778 < %(help_registered)s
        """ % {'help_registered': _(config.Messages.HELP_REGISTERED)}
        self.runScript(script)

        # Registered user
        contact = register_user(self, "779", "someone")
        script = """
          779 > help
          779 < %(help_registered)s
        """ % {'help_registered': _(config.Messages.HELP_REGISTERED)}
        self.runScript(script)
Exemplo n.º 28
0
 def testStop(self):
     contact = register_user(self, "778", "someone")
     script = """
       778 > stop
       778 < Umesitisha kukumbushwa kwenye hii namba. tafadhali tuma 'msaada' kupata maelekezo jinsi ya kujiunga tena
     """
     self.runScript(script)
     contact = Contact.objects.get(name="someone")
     self.assertFalse(contact.is_active)
Exemplo n.º 29
0
 def testLanguageEnglish(self):
     translation.activate("en")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > language en
         778 < %(language_confirm)s
         """ % {
         "language_confirm": _(config.Messages.LANGUAGE_CONFIRM) % {"language": "English"}
     }
     self.runScript(script)
Exemplo n.º 30
0
    def setUp(self):
        super(TestReportGroups, self).setUp()
        Contact.objects.all().delete()
        ProductReport.objects.all().delete()

        # district contact
        self.contact = register_user(self, "778", "someone")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        self.contact.supply_point = sp
        self.contact.save()
Exemplo n.º 31
0
    def setUp(self):
        super(TestReportGroups, self).setUp()
        Contact.objects.all().delete()
        ProductReport.objects.all().delete()

        # district contact
        self.contact = register_user(self, "778", "someone")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        self.contact.supply_point = sp
        self.contact.save()
Exemplo n.º 32
0
    def testDeliveryFacilityReportProductError(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")
        add_products(contact, ["id", "dp", "ip"])

        script = """
            778 > nimepokea Ig 400 Dp 569 Ip 678
            778 < %(error_message)s
            """ % {'error_message': _(config.Messages.INVALID_PRODUCT_CODE) % {"product_code":"ig"}}
        self.runScript(script)
Exemplo n.º 33
0
 def testLanguageSwahili(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > lugha sw
         778 < %(language_confirm)s
         """ % {
         "language_confirm": _(config.Messages.LANGUAGE_CONFIRM) % {"language": "Swahili"}
     }
     self.runScript(script)
Exemplo n.º 34
0
 def testLanguageUnknown(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > language de
         778 < %(language_unknown)s
         """ % {
         "language_unknown": _(config.Messages.LANGUAGE_UNKNOWN) % {"language": "de"}
     }
     self.runScript(script)
Exemplo n.º 35
0
    def testDeliveryDistrictReceived(self):
        #Should record a SupplyPointStatus and send out a notification to all the District's sub-facilities.

        # district contact
        self.contact = register_user(self, "778", "someone")
        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        self.contact.supply_point = sp
        self.contact.save()

        #facility contacts
        contact = register_user(self, "32346", "Person 1", "d30701",
                                "CHAUME DISP")
        contact = register_user(self, "32347", "Person 2", "d31049",
                                "CHIDEDE DISP")

        # submitted successfully
        translation.activate("sw")

        script = """
          778 > nimepokea
          778 < %(submitted_message)s
          32346 < %(delivery_confirm_children)s
          32347 < %(delivery_confirm_children)s
        """ % {
            "submitted_message":
            _(config.Messages.DELIVERY_CONFIRM_DISTRICT) % {
                "contact_name": "someone",
                "facility_name": "TANDAHIMBA"
            },
            "delivery_confirm_children":
            _(config.Messages.DELIVERY_CONFIRM_CHILDREN) % {
                "district_name": sp.name
            }
        }
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(
            supply_point=sp,
            status_type="del_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.RECEIVED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_DISTRICT,
                         sps.status_type)
Exemplo n.º 36
0
    def testStockOnHandKeywordsandLanguageSwahili(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md"]
        add_products(contact, product_codes)

        script = """
            +255714774042 > hmk fs100md100
            +255714774042 < %(soh_confirm)s
        """ % {"soh_confirm": _(config.Messages.SOH_CONFIRM)}
        self.runScript(script)
Exemplo n.º 37
0
    def testMessageInitiatorHelp(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")

        script = """
            778 > test
            778 < %(test_help)s
            """ % {
            "test_help": _(config.Messages.TEST_HANDLER_HELP)
        }
        self.runScript(script)
Exemplo n.º 38
0
    def testStockOnHandDelimitersStandard(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md", "ff", "dx", "bp", "pc", "qi"]
        add_products(contact, product_codes)

        #standard spacing
        script = """
            +255714774042 > hmk fs100 md100 ff100 dx100 bp100 pc100 qi100
            +255714774042 < %(soh_confirm)s
        """ % {"soh_confirm": _(config.Messages.SOH_CONFIRM)}
        self.runScript(script)
Exemplo n.º 39
0
    def testStockOnHandMixedDelimitersAndSpacing(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md", "ff", "pc", "qi", "bp", "dx"]
        add_products(contact, product_codes)

        #mixed - commas, spacing
        script = """
            +255714774042 > hmk fs100 , md100,ff 100 pc  100  qi,       1000,bp, 100, dx,100
            +255714774042 < %(soh_confirm)s
        """ % {"soh_confirm": _(config.Messages.SOH_PARTIAL_CONFIRM) % {"contact_name": "someone", "facility_name": "VETA 1", "product_list": "bp dx qi"}}
        self.runScript(script)
Exemplo n.º 40
0
    def testStockOnHandDelimitersExtraSpaces(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md", "ff", "pc"]
        add_products(contact, product_codes)

        #extra spaces
        script = """
            +255714774042 > hmk fs  100   md    100     ff      100       pc        100
            +255714774042 < %(soh_confirm)s
        """ % {"soh_confirm": _(config.Messages.SOH_CONFIRM)}
        self.runScript(script)
Exemplo n.º 41
0
 def testLanguageUnknown(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > language de
         778 < %(language_unknown)s
         """ % {
         'language_unknown': _(config.Messages.LANGUAGE_UNKNOWN) % {
             "language": "de"
         }
     }
     self.runScript(script)
Exemplo n.º 42
0
 def testLanguageEnglish(self):
     translation.activate("en")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > language en
         778 < %(language_confirm)s
         """ % {
         'language_confirm': _(config.Messages.LANGUAGE_CONFIRM) % {
             "language": "English"
         }
     }
     self.runScript(script)
Exemplo n.º 43
0
 def testLanguageSwahili(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone", "d10001")
     script = """
         778 > lugha sw
         778 < %(language_confirm)s
         """ % {
         'language_confirm': _(config.Messages.LANGUAGE_CONFIRM) % {
             "language": "Swahili"
         }
     }
     self.runScript(script)
Exemplo n.º 44
0
    def testStockOnHandKeywordsandLanguageSwahili(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md"]
        add_products(contact, product_codes)

        script = """
            +255714774042 > hmk fs100md100
            +255714774042 < %(soh_confirm)s
        """ % {
            "soh_confirm": _(config.Messages.SOH_CONFIRM)
        }
        self.runScript(script)
Exemplo n.º 45
0
    def testMessageInitiatorBadCode(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")

        script = """
            778 > test la d5000000
            778 < %(test_bad_code)s
            """ % {
            "test_bad_code": _(config.Messages.TEST_HANDLER_BAD_CODE) % {
                "code": "d5000000"
            }
        }
        self.runScript(script)
Exemplo n.º 46
0
    def testHelpRegistered(self):
        translation.activate("sw")

        # Registered user
        contact = register_user(self, "778", "someone")
        script = """
          778 > msaada
          778 < %(help_registered)s
        """ % {
            'help_registered': _(config.Messages.HELP_REGISTERED)
        }
        self.runScript(script)

        # Registered user
        contact = register_user(self, "779", "someone")
        script = """
          779 > help
          779 < %(help_registered)s
        """ % {
            'help_registered': _(config.Messages.HELP_REGISTERED)
        }
        self.runScript(script)
Exemplo n.º 47
0
    def testMessageInitiatorStockInquiryIndividualLocation(self):
        raise Exception("This feature hasn't been implemented yet")
        translation.activate("sw")
        contact = register_user(self, "32000", "Trainer", )
        contact = register_user(self, "32347", "Person 1", "d31049", "CHIDEDE DISP")
        contact = register_user(self, "32348", "Person 2", "d31049", "CHIDEDE DISP")
        contact = register_user(self, "32349", "Person 3", "d31049", "CHIDEDE DISP")

        p = Product.objects.get(sms_code__iexact="id")
        p.product_code = 'm11111'
        p.save()

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        translation.activate("sw")

        print p.name
        print p.product_code

        script = """
            32000 > test si d31049 m11112
            32000 < %(invalid_code_message)s 
            32000 > test si d31049 m11111
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            32000 > test si d10101 m11111
            32000 < %(location_error)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "response":_(config.Messages.STOCK_INQUIRY_MESSAGE) % {"product_name":p.name,
                                                                          "msd_code":p.product_code},
                   "invalid_code_message":_(config.Messages.INVALID_PRODUCT_CODE) % {"product_code":"m11112"},
                   "location_error":_(config.Messages.STOCK_INQUIRY_NOT_A_FACILITY_ERROR) % {"location_name":"changeme",
                                                                                             "location_type":"changeme"}}
        self.runScript(script)
Exemplo n.º 48
0
 def testSupervision(self):
     #TODO confirm actual supervision status
     contact = register_user(self, "778", "someone")
     script = """
       778 > usimamizi ndio
       778 < Asante, umetoa taarifa kuwa 'usimamizi ndiyo'
     """
     self.runScript(script)
     
     script = """
       778 > usimamizi hapana
       778 < Umetoa taarifa kuwa haujafanyiwa usimazi kwa mwezi huu.
     """
     self.runScript(script)        
Exemplo n.º 49
0
 def testDeliveryFacilityReceivedQuantitiesReported(self):
     translation.activate("sw")
     contact = register_user(self, "778", "someone", "d10001")
     add_products(contact, ["id", "dp", "ip"])
     
     script = """
         778 > nimepokea Id 400 Dp 569 Ip 678
         778 < %(received_message)s
         """ % {'received_message': _(config.Messages.DELIVERED_CONFIRM) % {"reply_list":"dp,id,ip"}}
     self.runScript(script)
     self.assertEqual(3, ProductStock.objects.count())
     for ps in ProductStock.objects.all():
         self.assertEqual(contact.supply_point, ps.supply_point)
         self.assertTrue(0 != ps.quantity)
Exemplo n.º 50
0
    def testDeliveryFacilityReportProductError(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")
        add_products(contact, ["id", "dp", "ip"])

        script = """
            778 > nimepokea Ig 400 Dp 569 Ip 678
            778 < %(error_message)s
            """ % {
            'error_message': _(config.Messages.INVALID_PRODUCT_CODE) % {
                "product_code": "ig"
            }
        }
        self.runScript(script)
Exemplo n.º 51
0
    def testStockOnHandDelimitersExtraSpaces(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md", "ff", "pc"]
        add_products(contact, product_codes)

        #extra spaces
        script = """
            +255714774042 > hmk fs  100   md    100     ff      100       pc        100
            +255714774042 < %(soh_confirm)s
        """ % {
            "soh_confirm": _(config.Messages.SOH_CONFIRM)
        }
        self.runScript(script)
Exemplo n.º 52
0
    def testStockOnHandDelimitersStandard(self):
        translation.activate("sw")
        contact = register_user(self, "+255714774042", "someone")
        product_codes = ["fs", "md", "ff", "dx", "bp", "pc", "qi"]
        add_products(contact, product_codes)

        #standard spacing
        script = """
            +255714774042 > hmk fs100 md100 ff100 dx100 bp100 pc100 qi100
            +255714774042 < %(soh_confirm)s
        """ % {
            "soh_confirm": _(config.Messages.SOH_CONFIRM)
        }
        self.runScript(script)
Exemplo n.º 53
0
    def testMessageInitiatorThankYouDistrict(self):
        translation.activate("sw")
        register_user(self, "32000", "Trainer", )
        register_user(self, "32347", "Person 1", "d31049", "CHIDEDE DISP")
        register_user(self, "32348", "Person 2", "d31049", "CHIDEDE DISP")
        register_user(self, "32349", "Person 3", "d31049", "CHIDEDE DISP")

        script = """
            32000 > test soh_thank_you d31049
            32000 < %(test_handler_confirm)s
            32347 < %(response)s
            32348 < %(response)s
            32349 < %(response)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "response":_(config.Messages.SOH_THANK_YOU)}
        self.runScript(script)
Exemplo n.º 54
0
    def testSupervision(self):
        #TODO confirm actual supervision status
        contact = register_user(self, "778", "someone")
        script = """
          778 > usimamizi ndio
          778 < Asante, umetoa taarifa kuwa 'usimamizi ndiyo'
        """
        self.runScript(script)

        script = """
          778 > usimamizi hapana
          778 < Umetoa taarifa kuwa haujafanyiwa usimazi kwa mwezi huu.
        """
        self.runScript(script)
Exemplo n.º 55
0
    def testMessageInitiatorDeliveryDistrict(self):
        translation.activate("sw")

        contact = register_user(
            self,
            "32000",
            "Trainer",
        )

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        for contact_id in ["+255714774041", "+255714774042", "+255714774043"]:
            register_user(self, contact_id, "Person %s" % contact_id, "d10101",
                          "TANDAHIMBA")

        script = """
            32000 > test delivery d10101
            32000 < %(test_handler_confirm)s
            +255714774041 < %(response)s
            +255714774042 < %(response)s
            +255714774043 < %(response)s
            """ % {
            "test_handler_confirm": _(config.Messages.TEST_HANDLER_CONFIRM),
            "response": _(config.Messages.DELIVERY_REMINDER_DISTRICT)
        }
        self.runScript(script)

        sps = SupplyPointStatus.objects.filter(
            supply_point=sp,
            status_type="del_dist").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.REMINDER_SENT,
                         sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_DISTRICT,
                         sps.status_type)
Exemplo n.º 56
0
    def setUp(self):
        super(TestReportSummaryBase, self).setUp()
        Contact.objects.all().delete()
        ProductReport.objects.all().delete()

        self.district_contact = register_user(self, "777", "someone")
        sp = SupplyPoint.objects.get(name="TEST DISTRICT")
        sp.groups = (SupplyPointGroup.objects.get\
                     (code=DeliveryGroups().current_submitting_group()),)
        self.district_contact.supply_point = sp
        self.district_contact.save()

        contact1 = register_user(self, "778", "Test User1", "d10001", "VETA 1")
        contact2 = register_user(self, "779", "Test User2", "d10002", "VETA 2")
        contact3 = register_user(self, "780", "Test User3", "d10003", "VETA 3")
        self.facility_contacts = [contact1, contact2, contact3]
        for contact in self.facility_contacts:
            # make sure parentage is right
            self.assertEqual(contact.supply_point.supplied_by,
                             self.district_contact.supply_point)
            # make sure group is right
            contact.supply_point.groups = (SupplyPointGroup.objects.get\
                                           (code=self.relevant_group),)
            contact.supply_point.save()
Exemplo n.º 57
0
    def setUp(self):
        super(TestReportSummaryBase, self).setUp()
        Contact.objects.all().delete()
        ProductReport.objects.all().delete()

        self.district_contact = register_user(self, "777", "someone")
        sp = SupplyPoint.objects.get(name="TEST DISTRICT")
        sp.groups = (SupplyPointGroup.objects.get\
                     (code=DeliveryGroups().current_submitting_group()),)
        self.district_contact.supply_point = sp
        self.district_contact.save()
        
        contact1 = register_user(self, "778", "Test User1", "d10001", "VETA 1")
        contact2 = register_user(self, "779", "Test User2", "d10002", "VETA 2")
        contact3 = register_user(self, "780", "Test User3", "d10003", "VETA 3")
        self.facility_contacts = [contact1, contact2, contact3]
        for contact in self.facility_contacts:
            # make sure parentage is right
            self.assertEqual(contact.supply_point.supplied_by,
                             self.district_contact.supply_point)
            # make sure group is right 
            contact.supply_point.groups = (SupplyPointGroup.objects.get\
                                           (code=self.relevant_group),)
            contact.supply_point.save()
Exemplo n.º 58
0
    def testMessageInitiatorLateDeliveryReportDistrict(self):
        translation.activate("sw")

        register_user(self, "32000", "Trainer", )

        sp = SupplyPoint.objects.get(name="TANDAHIMBA")
        sp.code = "D10101"
        sp.save()

        for contact_id in ["+255714774041","+255714774042","+255714774043"]:
            register_user(self, contact_id, "Person %s" % contact_id, "d10101", "TANDAHIMBA")

        script = """
            32000 > test latedelivery d10101
            32000 < %(test_handler_confirm)s
            +255714774041 < %(response)s
            +255714774042 < %(response)s
            +255714774043 < %(response)s
            """ % {"test_handler_confirm":_(config.Messages.TEST_HANDLER_CONFIRM),
                   "response":_(config.Messages.DELIVERY_LATE_DISTRICT) % {"group_name":"changeme",
                                                                           "group_total":1,
                                                                           "not_responded_count":2,
                                                                           "not_received_count":3}}
        self.runScript(script)
Exemplo n.º 59
0
    def testDeliveryFacilityNotReceived(self):
        translation.activate("sw")
        contact = register_user(self, "778", "someone", "d10001")

        script = """
            778 > sijapokea
            778 < %(not_received_message)s
            """ % {'not_received_message': _(config.Messages.NOT_DELIVERED_CONFIRM)}
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D10001")
        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="del_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.NOT_RECEIVED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.DELIVERY_FACILITY, sps.status_type)
Exemplo n.º 60
0
    def testRandRNotSubmitted(self):
        contact = register_user(self, "778", "someone", "d10001")

        #not submitted
        translation.activate("sw")
        sp = SupplyPoint.objects.get(code="D10001")
        script = """
          778 > sijatuma
          778 < %(not_submitted_message)s
        """ % {'not_submitted_message': _(config.Messages.NOT_SUBMITTED_CONFIRM)}
        self.runScript(script)

        sp = SupplyPoint.objects.get(code="D10001")
        sps = SupplyPointStatus.objects.filter(supply_point=sp,
                                         status_type="rr_fac").order_by("-status_date")[0]

        self.assertEqual(SupplyPointStatusValues.NOT_SUBMITTED, sps.status_value)
        self.assertEqual(SupplyPointStatusTypes.R_AND_R_FACILITY, sps.status_type)