Esempio n. 1
0
    def testParseProgramJson(self):
        with open(os.path.join(self.datapath, 'sample_program.json')) as f:
            program = Program.from_json(json.loads(f.read()))

        self.assertEqual('ESS_MEDS', program.code)
        self.assertEqual('ESSENTIAL MEDICINES', program.name)
        self.assertEqual(35, len(program.products))
        p = program.products[0]
        self.assertEqual('P75', p.code)
        self.assertEqual('Malaria Rapid Diagnostics Tests', p.name)
        self.assertEqual('P75', p.code)
        self.assertEqual('TDF/FTC/EFV', p.description)
        self.assertEqual(10, p.unit)
        self.assertEqual('Analgesics', p.category)
 def testSyncRequisition(self):
     with open(os.path.join(self.datapath, 'sample_program.json')) as f:
         lmis_program = Program.from_json(json.loads(f.read()))
     commtrack_program = sync_openlmis_program(TEST_DOMAIN, lmis_program)
     test_product = {
         'name': 'Test',
         'code': 'P151',
         'unit': 10,
         'description': 'decs',
         'category': 'category',
     }
     sync_openlmis_product(TEST_DOMAIN, commtrack_program, test_product)
     sync_requisition_from_openlmis(TEST_DOMAIN, 1, self.api)
     self.assertTrue(1, len(RequisitionCase.get_by_external(TEST_DOMAIN, 1)))
Esempio n. 3
0
    def testParseProgramJson(self):
        with open(os.path.join(self.datapath, 'sample_program.json')) as f:
            program = Program.from_json(json.loads(f.read()))

        self.assertEqual('ESS_MEDS', program.code)
        self.assertEqual('ESSENTIAL MEDICINES', program.name)
        self.assertEqual(35, len(program.products))
        p = program.products[0]
        self.assertEqual('P75', p.code)
        self.assertEqual('Malaria Rapid Diagnostics Tests', p.name)
        self.assertEqual('P75', p.code)
        self.assertEqual('TDF/FTC/EFV', p.description)
        self.assertEqual(10, p.unit)
        self.assertEqual('Analgesics', p.category)
 def fixmetestSyncRequisition(self):
     with open(os.path.join(self.datapath, 'sample_program.json')) as f:
         lmis_program = Program.from_json(json.loads(f.read()))
     commtrack_program = sync_openlmis_program(TEST_DOMAIN, lmis_program)
     test_product = LMISProduct.from_json({
         "programCode": "ESS_MEDS",
         "programName": "ESSENTIAL MEDICINES",
         "productCode": "P26",
         "productName": "Erythromycin ethyl succinate, pwd oral suspension, 125mg/5ml",
         "description": "TDF/FTC/EFV",
         "unit": 10,
         "category": "Analgesics"
     })
     sync_openlmis_product(TEST_DOMAIN, commtrack_program, test_product)
     sync_requisition_from_openlmis(TEST_DOMAIN, 1, self.api)
     self.assertTrue(1, len(RequisitionCase.get_by_external(TEST_DOMAIN, 1)))
 def fixmetestSyncRequisition(self):
     with open(os.path.join(self.datapath, 'sample_program.json')) as f:
         lmis_program = Program.from_json(json.loads(f.read()))
     commtrack_program = sync_openlmis_program(TEST_DOMAIN, lmis_program)
     test_product = LMISProduct.from_json({
         "programCode": "ESS_MEDS",
         "programName": "ESSENTIAL MEDICINES",
         "productCode": "P26",
         "productName":
         "Erythromycin ethyl succinate, pwd oral suspension, 125mg/5ml",
         "description": "TDF/FTC/EFV",
         "unit": 10,
         "category": "Analgesics"
     })
     sync_openlmis_product(TEST_DOMAIN, commtrack_program, test_product)
     sync_requisition_from_openlmis(TEST_DOMAIN, 1, self.api)
     self.assertTrue(1, len(RequisitionCase.get_by_external(TEST_DOMAIN,
                                                            1)))
    def testCreateProgram(self):
        with open(os.path.join(self.datapath, 'sample_program.json')) as f:
            lmis_program = Program.from_json(json.loads(f.read()))

        # program sync
        self.assertEqual(0, len(Product.by_domain(TEST_DOMAIN)))
        commtrack_program = sync_openlmis_program(TEST_DOMAIN, lmis_program)
        self.assertEqual(lmis_program.name, commtrack_program.name)
        self.assertEqual(lmis_program.code, commtrack_program.code)

        # product sync
        self.assertEqual(len(lmis_program.products), len(Product.by_domain(TEST_DOMAIN)))
        lmis_product = lmis_program.products[0]
        product = Product.get_by_code(TEST_DOMAIN, lmis_product.code)
        self.assertEqual(product.code, lmis_product.code)
        self.assertEqual(product.name, lmis_product.name)
        self.assertEqual(product.description, lmis_product.description)
        self.assertEqual(product.unit, str(lmis_product.unit))
        self.assertEqual(product.category, str(lmis_product.category))
Esempio n. 7
0
    def testCreateProgram(self):
        with open(os.path.join(self.datapath, 'sample_program.json')) as f:
            lmis_program = Program.from_json(json.loads(f.read()))

        # program sync
        self.assertEqual(0, len(Product.by_domain(TEST_DOMAIN)))
        commtrack_program = sync_openlmis_program(TEST_DOMAIN, lmis_program)
        self.assertEqual(lmis_program.name, commtrack_program.name)
        self.assertEqual(lmis_program.code.lower(), commtrack_program.code)

        # product sync
        self.assertEqual(len(lmis_program.products),
                         len(Product.by_domain(TEST_DOMAIN)))
        lmis_product = lmis_program.products[0]
        product = Product.get_by_code(TEST_DOMAIN, lmis_product.code)
        self.assertEqual(product.code, lmis_product.code.lower())
        self.assertEqual(product.name, lmis_product.name)
        self.assertEqual(product.description, lmis_product.description)
        self.assertEqual(product.unit, str(lmis_product.unit))
        self.assertEqual(product.category, str(lmis_product.category))