Пример #1
0
 def testReportEmergencyForAnotherHSA(self):
     create_manager(self, "16175551234", "charles", role="ic")
     create_hsa(self, "16175551000", "joe")
     create_hsa(self, "16175551001", "phoneless", "2")
     a = """
        16175551000 > report 261602 eo zi 40 la 200 
        16175551000 < %(response)s
        16175551234 < %(super)s
     """ % {"response": config.Messages.EMERGENCY_SOH % \
            {"products": "zi la"},
            "super": config.Messages.SUPERVISOR_EMERGENCY_SOH_NOTIFICATION % \
            {"hsa": "phoneless", "emergency_products": "zi 160",
             "normal_products": "la 160",
             "hsa_id": "261602"}}
     self.runScript(a)
     hsa_sp = SupplyPoint.objects.get(code="261602")
     self.assertEqual(
         40,
         ProductStock.objects.get(supply_point=hsa_sp,
                                  product__sms_code="zi").quantity)
     self.assertEqual(
         200,
         ProductStock.objects.get(supply_point=hsa_sp,
                                  product__sms_code="la").quantity)
     self.assertEqual(2, StockRequest.objects.count())
     for req in StockRequest.objects.all():
         self.assertEqual(hsa_sp, req.supply_point)
         self.assertEqual(StockRequestStatus.REQUESTED, req.status)
         self.assertTrue(req.is_pending())
         if req.is_emergency:
             self.assertTrue(Product.by_code("zi"), req.product)
         else:
             self.assertTrue(Product.by_code("la"), req.product)
Пример #2
0
 def testReportEmergencyForAnotherHSA(self):
     create_manager(self, "16175551234", "charles", role="ic")
     create_hsa(self, "16175551000", "joe")
     create_hsa(self, "16175551001", "phoneless", "2")
     a = """
        16175551000 > report 261602 eo zi 40 la 200 
        16175551000 < %(response)s
        16175551234 < %(super)s
     """ % {"response": config.Messages.EMERGENCY_SOH % \
            {"products": "zi la"},
            "super": config.Messages.SUPERVISOR_EMERGENCY_SOH_NOTIFICATION % \
            {"hsa": "phoneless", "emergency_products": "zi 160",
             "normal_products": "la 160",
             "hsa_id": "261602"}}
     self.runScript(a)
     hsa_sp = SupplyPoint.objects.get(code="261602")
     self.assertEqual(40, ProductStock.objects.get(supply_point=hsa_sp, product__sms_code="zi").quantity)
     self.assertEqual(200, ProductStock.objects.get(supply_point=hsa_sp, product__sms_code="la").quantity)
     self.assertEqual(2, StockRequest.objects.count())
     for req in StockRequest.objects.all():
         self.assertEqual(hsa_sp, req.supply_point)
         self.assertEqual(StockRequestStatus.REQUESTED, req.status)
         self.assertTrue(req.is_pending())
         if req.is_emergency:
             self.assertTrue(Product.by_code("zi"), req.product)
         else:
             self.assertTrue(Product.by_code("la"), req.product)
Пример #3
0
    def testBasicTransfer(self):
        create_hsa(self, "16175551000", "wendy", products="zi")
        create_hsa(self, "16175551001", "steve", id="2", products="zi")
        a = """
           16175551000 > soh zi 100
           16175551000 < %(no_super)s
           16175551001 > soh zi 10
           16175551001 < %(no_super)s
        """ % {
            "no_super": config.Messages.NO_IN_CHARGE % {
                "supply_point": "Ntaja"
            }
        }
        self.runScript(a)
        stock_from = ProductStock.objects.get(
            supply_point=SupplyPoint.objects.get(code="261601"),
            product=Product.by_code("zi"))
        stock_to = ProductStock.objects.get(
            supply_point=SupplyPoint.objects.get(code="261602"),
            product=Product.by_code("zi"))
        self.assertEqual(100, stock_from.quantity)
        self.assertEqual(10, stock_to.quantity)

        b = """
           16175551000 > give 261602 zi 20
           16175551000 < %(confirm)s
           16175551001 < Confirm receipt of zi 20 from wendy? Please respond 'confirm'
        """ % {"confirm": config.Messages.TRANSFER_RESPONSE % \
                    {"giver": "wendy", "receiver": "steve",
                     "reporter": "wendy", "products": "zi 20"}}
        self.runScript(b)
        self.assertEqual(80,
                         ProductStock.objects.get(pk=stock_from.pk).quantity)
        self.assertEqual(10, ProductStock.objects.get(pk=stock_to.pk).quantity)
        [st] = StockTransfer.objects.all()
        self.assertTrue(st.is_pending())
        self.assertEqual(20, st.amount)
        self.assertEqual(Product.by_code("zi"), st.product)
        self.assertEqual(SupplyPoint.objects.get(code="261601"), st.giver)
        self.assertEqual(SupplyPoint.objects.get(code="261602"), st.receiver)

        c = """
           16175551001 > confirm
           16175551001 < Thank you steve. You have confirmed receipt of the following products: zi 20
        """
        self.runScript(c)
        self.assertEqual(80,
                         ProductStock.objects.get(pk=stock_from.pk).quantity)
        self.assertEqual(30, ProductStock.objects.get(pk=stock_to.pk).quantity)
        [st] = StockTransfer.objects.all()
        self.assertTrue(st.is_closed())
Пример #4
0
 def testBasicTransfer(self):
     create_hsa(self, "16175551000", "wendy", products="zi")
     create_hsa(self, "16175551001", "steve", id="2", products="zi")
     a = """
        16175551000 > soh zi 100
        16175551000 < %(no_super)s
        16175551001 > soh zi 10
        16175551001 < %(no_super)s
     """ % {"no_super": config.Messages.NO_IN_CHARGE % {"supply_point": "Ntaja"}}
     self.runScript(a)
     stock_from = ProductStock.objects.get(supply_point=SupplyPoint.objects.get(code="261601"), 
                                           product=Product.by_code("zi"))
     stock_to = ProductStock.objects.get(supply_point=SupplyPoint.objects.get(code="261602"), 
                                         product=Product.by_code("zi"))
     self.assertEqual(100, stock_from.quantity)
     self.assertEqual(10, stock_to.quantity)
     
     b = """
        16175551000 > give 261602 zi 20
        16175551000 < %(confirm)s
        16175551001 < Confirm receipt of zi 20 from wendy? Please respond 'confirm'
     """ % {"confirm": config.Messages.TRANSFER_RESPONSE % \
                 {"giver": "wendy", "receiver": "steve", 
                  "reporter": "wendy", "products": "zi 20"}}
     self.runScript(b)
     self.assertEqual(80, ProductStock.objects.get(pk=stock_from.pk).quantity)
     self.assertEqual(10, ProductStock.objects.get(pk=stock_to.pk).quantity)
     [st] = StockTransfer.objects.all()
     self.assertTrue(st.is_pending())
     self.assertEqual(20, st.amount)
     self.assertEqual(Product.by_code("zi"), st.product)
     self.assertEqual(SupplyPoint.objects.get(code="261601"), st.giver)
     self.assertEqual(SupplyPoint.objects.get(code="261602"), st.receiver)
     
     c = """
        16175551001 > confirm
        16175551001 < Thank you steve. You have confirmed receipt of the following products: zi 20
     """
     self.runScript(c)
     self.assertEqual(80, ProductStock.objects.get(pk=stock_from.pk).quantity)
     self.assertEqual(30, ProductStock.objects.get(pk=stock_to.pk).quantity)
     [st] = StockTransfer.objects.all()
     self.assertTrue(st.is_closed())
Пример #5
0
 def testReportEmergencyTransfers(self):
     create_hsa(self, "16175551000", "giver")
     create_hsa(self, "16175551001", "receiver", "2")
     create_hsa(self, "16175551002", "reporter", "3")
     a = """
        16175551002 > report 261601 give 261602 zi 20
        16175551002 < %(response)s
        16175551001 < %(receive)s
     """ % {"response": config.Messages.TRANSFER_RESPONSE % \
            {"reporter": "reporter", "giver": "giver",
             "receiver": "receiver", "products": "zi 20"},
            "receive": config.Messages.TRANSFER_CONFIRM % \
            {"products": "zi 20", "giver": "giver"}}
     self.runScript(a)
     [st] = StockTransfer.objects.all()
     self.assertTrue(st.is_pending())
     self.assertEqual(20, st.amount)
     self.assertEqual(Product.by_code("zi"), st.product)
     self.assertEqual(SupplyPoint.objects.get(code="261601"), st.giver)
     self.assertEqual(SupplyPoint.objects.get(code="261602"), st.receiver)
Пример #6
0
 def testReportEmergencyTransfers(self):
     create_hsa(self, "16175551000", "giver")
     create_hsa(self, "16175551001", "receiver", "2")
     create_hsa(self, "16175551002", "reporter", "3")
     a = """
        16175551002 > report 261601 give 261602 zi 20
        16175551002 < %(response)s
        16175551001 < %(receive)s
     """ % {"response": config.Messages.TRANSFER_RESPONSE % \
            {"reporter": "reporter", "giver": "giver", 
             "receiver": "receiver", "products": "zi 20"},
            "receive": config.Messages.TRANSFER_CONFIRM % \
            {"products": "zi 20", "giver": "giver"}}
     self.runScript(a)
     [st] = StockTransfer.objects.all()
     self.assertTrue(st.is_pending())
     self.assertEqual(20, st.amount)
     self.assertEqual(Product.by_code("zi"), st.product)
     self.assertEqual(SupplyPoint.objects.get(code="261601"), st.giver)
     self.assertEqual(SupplyPoint.objects.get(code="261602"), st.receiver)