예제 #1
0
 def setUpClass(cls):
     super(UrgentNonReportingNotificationTestCase, cls).setUpClass()
     delete_all_users()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(cls.TEST_DOMAIN)
     cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
     cls.program.save()
예제 #2
0
    def setUpClass(cls):
        super(TestUrgentAlerts, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN)
        cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc2 = make_loc(code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc3 = make_loc(code="tf3", name="Test Facility 3", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc4 = make_loc(code="tf4", name="Test Facility 4", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)

        cls.product = Product(domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each')
        cls.product.save()

        cls.product2 = Product(domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each')
        cls.product2.save()

        cls.user1 = bootstrap_web_user(
            username='******', phone_number='1111', location=cls.district, domain=TEST_DOMAIN,
            first_name='test', last_name='test1',
            user_data={
                'role': []
            }, email='*****@*****.**', password='******'
        )

        set_sms_notifications(TEST_DOMAIN, cls.user1, True)
예제 #3
0
 def setUpClass(cls):
     super(UrgentNonReportingNotificationTestCase, cls).setUpClass()
     delete_all_users()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(cls.TEST_DOMAIN)
     cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
     cls.program.save()
예제 #4
0
    def setUpClass(cls):
        super(TestUrgentAlerts, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN)
        cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc2 = make_loc(code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc3 = make_loc(code="tf3", name="Test Facility 3", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc4 = make_loc(code="tf4", name="Test Facility 4", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)

        cls.product = Product(domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each')
        cls.product.save()

        cls.product2 = Product(domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each')
        cls.product2.save()

        cls.user1 = bootstrap_web_user(
            username='******', phone_number='1111', location=cls.district, domain=TEST_DOMAIN,
            first_name='test', last_name='test1',
            user_data={
                'role': []
            }, email='*****@*****.**', password='******'
        )

        set_sms_notifications(TEST_DOMAIN, cls.user1, True)
예제 #5
0
    def setUpClass(cls):
        cls.domain = prepare_domain(cls.TEST_DOMAIN)
        cls.sms_backend_mapping, cls.backend = create_backend()

        cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
        cls.program.save()

        cls.program2 = Program(domain=cls.TEST_DOMAIN, name='Test Program2')
        cls.program2.save()
예제 #6
0
    def setUpClass(cls):
        super(EWSTestCase, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)

        cls.national = make_loc(code='national', name='National', type='country', domain=TEST_DOMAIN)
        cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN,
                              parent=cls.national)
        cls.rms = make_loc(code="rms", name="Test Medical Store", type="Regional Medical Store",
                           domain=TEST_DOMAIN, parent=cls.region)
        cls.rms2 = make_loc(code="rms2", name="Test Medical Store 2", type="Regional Medical Store",
                            domain=TEST_DOMAIN, parent=cls.region)
        cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN)
        cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)
        cls.loc2 = make_loc(code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN,
                            parent=cls.district)

        cls.user1 = bootstrap_web_user(
            username='******', phone_number='1111', location=cls.district, domain=TEST_DOMAIN,
            first_name='test', last_name='test1',
            user_data={
                'role': []
            }, email='*****@*****.**', password='******'
        )

        set_sms_notifications(TEST_DOMAIN, cls.user1, True)

        cls.national_user = bootstrap_web_user(
            username='******', phone_number='2222', location=cls.national, domain=TEST_DOMAIN,
            first_name='test', last_name='test2',
            user_data={
                'role': []
            }, email='*****@*****.**', password='******'
        )

        set_sms_notifications(TEST_DOMAIN, cls.national_user, True)

        cls.regional_user = bootstrap_web_user(
            username='******', phone_number='4444', location=cls.region, domain=TEST_DOMAIN,
            first_name='test', last_name='test4',
            user_data={
                'role': []
            }, email='*****@*****.**', password='******'
        )

        set_sms_notifications(TEST_DOMAIN, cls.regional_user, True)

        cls.product = Product(domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each')
        cls.product.save()

        cls.product2 = Product(domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each')
        cls.product2.save()

        assign_products_to_location(cls.loc1, [cls.product])
        assign_products_to_location(cls.loc2, [cls.product, cls.product2])
        assign_products_to_location(cls.rms, [cls.product, cls.product2])
예제 #7
0
    def setUpClass(cls):
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(cls.TEST_DOMAIN)

        cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
        cls.program.save()

        cls.program2 = Program(domain=cls.TEST_DOMAIN, name='Test Program2')
        cls.program2.save()
예제 #8
0
    def setUpClass(cls):
        super(MissingReportNotificationTestCase, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(cls.TEST_DOMAIN)

        cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
        cls.program.save()

        cls.program2 = Program(domain=cls.TEST_DOMAIN, name='Test Program2')
        cls.program2.save()
예제 #9
0
    def setUpClass(cls):
        super(MissingReportNotificationTestCase, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(cls.TEST_DOMAIN)

        cls.program = Program(domain=cls.TEST_DOMAIN, name='Test Program')
        cls.program.save()

        cls.program2 = Program(domain=cls.TEST_DOMAIN, name='Test Program2')
        cls.program2.save()
예제 #10
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each')
        p.save()
        p2 = Product(domain=domain.name,
                     name='Male Condom',
                     code='mc',
                     unit='each')
        p2.save()
        p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each')
        p3.save()
        p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each')
        p4.save()
        p5 = Product(domain=domain.name,
                     name='Micro-G',
                     code='mg',
                     unit='each')
        p5.save()
        loc = make_loc(code="garms",
                       name="Test RMS",
                       type="Regional Medical Store",
                       domain=domain.name)
        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(username='******',
                                   first_name='test1',
                                   last_name='test1',
                                   domain=domain.name,
                                   home_loc=loc)
        cls.user2 = bootstrap_user(username='******',
                                   domain=domain.name,
                                   home_loc=loc,
                                   first_name='test2',
                                   last_name='test2',
                                   phone_number='222222',
                                   user_data={'role': 'In Charge'})

        try:
            XFormInstance.get(docid='test-xform')
        except ResourceNotFound:
            xform = XFormInstance(_id='test-xform')
            xform.save()
        sql_location = loc.sql_location
        sql_location.products = SQLProduct.objects.filter(product_id=p5.get_id)
        sql_location.save()
        config = CommtrackConfig.for_domain(domain.name)
        config.actions.append(
            CommtrackActionConfig(action='receipts',
                                  keyword='rec',
                                  caption='receipts'))
        config.consumption_config = ConsumptionConfig(min_transactions=0,
                                                      min_window=0,
                                                      optimal_window=60)
        config.save()
예제 #11
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each')
        p.save()
        p2 = Product(domain=domain.name, name='Male Condom', code='mc', unit='each')
        p2.save()
        p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each')
        p3.save()
        p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each')
        p4.save()
        p5 = Product(domain=domain.name, name='Micro-G', code='mg', unit='each')
        p5.save()
        loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=domain.name)
        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(username='******', first_name='test1', last_name='test1',
                                   domain=domain.name, home_loc=loc)
        cls.user2 = bootstrap_user(username='******', domain=domain.name, home_loc=loc,
                                   first_name='test2', last_name='test2',
                                   phone_number='222222', user_data={'role': 'In Charge'})

        try:
            XFormInstance.get(docid='test-xform')
        except ResourceNotFound:
            xform = XFormInstance(_id='test-xform')
            xform.save()
        sql_location = loc.sql_location
        sql_location.products = SQLProduct.objects.filter(product_id=p5.get_id)
        sql_location.save()
        config = CommtrackConfig.for_domain(domain.name)
        config.actions.append(
            CommtrackActionConfig(
                action='receipts',
                keyword='rec',
                caption='receipts'
            )
        )
        config.consumption_config = ConsumptionConfig(min_transactions=0, min_window=0, optimal_window=60)
        config.save()
예제 #12
0
 def setUpClass(cls):
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(TEST_DOMAIN)
예제 #13
0
 def setUpClass(cls):
     super(SMSNotificationTestCase, cls).setUpClass()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(cls.TEST_DOMAIN)
예제 #14
0
    def setUpClass(cls):
        super(TestReminders, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.loc1 = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=TEST_DOMAIN)
        cls.loc2 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN)
        cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN)

        cls.user1 = bootstrap_user(
            username='******', phone_number='1111', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test1',
            user_data={
                'role': []
            }
        )
        cls.user2 = bootstrap_user(
            username='******', phone_number='2222', home_loc=cls.loc1, domain=TEST_DOMAIN,
            first_name='test', last_name='test2',
            user_data={
                'role': ['Other'],
                'needs_reminders': "False"
            }
        )

        cls.user3 = bootstrap_user(
            username='******', phone_number='3333', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test3',
            user_data={
                'role': ['Nurse'],
                'needs_reminders': "True"
            }
        )

        cls.in_charge = bootstrap_user(
            username='******', phone_number='4444', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test4',
            user_data={
                'role': ['In Charge']
            }
        )

        cls.web_user = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username='******',
            password='******',
            email='*****@*****.**',
            location=cls.loc2,
            phone_number='5555'
        )

        EWSExtension.objects.create(
            domain=TEST_DOMAIN,
            user_id=cls.web_user.get_id,
            sms_notifications=True,
            location_id=cls.loc2.get_id
        )

        cls.web_user2 = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username='******',
            password='******',
            email='*****@*****.**',
            location=cls.region,
            phone_number='6666'
        )

        set_sms_notifications(TEST_DOMAIN, cls.web_user2, True)

        FacilityInCharge.objects.create(
            user_id=cls.in_charge.get_id,
            location=cls.loc2.sql_location
        )

        cls.product = Product(
            domain=TEST_DOMAIN,
            name='Test Product',
            code_='tp',
            unit='each'
        )
        cls.product.save()

        cls.product2 = Product(
            domain=TEST_DOMAIN,
            name='Test Product2',
            code_='tp2',
            unit='each'
        )
        cls.product2.save()

        sql_product = SQLProduct.objects.get(product_id=cls.product.get_id)
        sql_product2 = SQLProduct.objects.get(product_id=cls.product2.get_id)

        sql_location1 = cls.loc1.sql_location
        sql_location2 = cls.loc2.sql_location

        sql_location1.products = [sql_product]
        sql_location2.products = [sql_product, sql_product2]
        sql_location1.save()
        sql_location2.save()
예제 #15
0
    def setUpClass(cls):
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.sms_backend_mapping, cls.backend = create_backend()

        cls.national = make_loc(code="national", name="National", type="country", domain=TEST_DOMAIN)
        cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN, parent=cls.national)
        cls.rms = make_loc(
            code="rms", name="Test Medical Store", type="Regional Medical Store", domain=TEST_DOMAIN, parent=cls.region
        )
        cls.rms2 = make_loc(
            code="rms2",
            name="Test Medical Store 2",
            type="Regional Medical Store",
            domain=TEST_DOMAIN,
            parent=cls.region,
        )
        cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN)
        cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN, parent=cls.district)
        cls.loc2 = make_loc(
            code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN, parent=cls.district
        )

        cls.user1 = bootstrap_web_user(
            username="******",
            phone_number="1111",
            location=cls.district,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test1",
            user_data={"role": []},
            email="*****@*****.**",
            password="******",
        )

        set_sms_notifications(TEST_DOMAIN, cls.user1, True)

        cls.national_user = bootstrap_web_user(
            username="******",
            phone_number="2222",
            location=cls.national,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test2",
            user_data={"role": []},
            email="*****@*****.**",
            password="******",
        )

        set_sms_notifications(TEST_DOMAIN, cls.national_user, True)

        cls.regional_user = bootstrap_web_user(
            username="******",
            phone_number="4444",
            location=cls.region,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test4",
            user_data={"role": []},
            email="*****@*****.**",
            password="******",
        )

        set_sms_notifications(TEST_DOMAIN, cls.regional_user, True)

        cls.product = Product(domain=TEST_DOMAIN, name="Test Product", code_="tp", unit="each")
        cls.product.save()

        cls.product2 = Product(domain=TEST_DOMAIN, name="Test Product2", code_="tp2", unit="each")
        cls.product2.save()

        assign_products_to_location(cls.loc1, [cls.product])
        assign_products_to_location(cls.loc2, [cls.product, cls.product2])
        assign_products_to_location(cls.rms, [cls.product, cls.product2])
예제 #16
0
    def setUpClass(cls):
        super(EWSScriptTest, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        domain = prepare_domain(TEST_DOMAIN)

        p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each')
        p.save()
        p2 = Product(domain=domain.name,
                     name='Male Condom',
                     code='mc',
                     unit='each')
        p2.save()
        p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each')
        p3.save()
        p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each')
        p4.save()
        p5 = Product(domain=domain.name,
                     name='Micro-G',
                     code='mg',
                     unit='each')
        p5.save()

        Product(domain=domain.name, name='Ad', code='ad', unit='each').save()
        Product(domain=domain.name, name='Al', code='al', unit='each').save()
        Product(domain=domain.name, name='Qu', code='qu', unit='each').save()
        Product(domain=domain.name, name='Sp', code='sp', unit='each').save()
        Product(domain=domain.name, name='Rd', code='rd', unit='each').save()
        Product(domain=domain.name, name='Ov', code='ov', unit='each').save()
        Product(domain=domain.name, name='Ml', code='ml', unit='each').save()

        national = make_loc(code='country',
                            name='Test national',
                            type='country',
                            domain=domain.name)
        region = make_loc(code='region',
                          name='Test region',
                          type='region',
                          domain=domain.name,
                          parent=national)
        loc = make_loc(code="garms",
                       name="Test RMS",
                       type="Regional Medical Store",
                       domain=domain.name,
                       parent=national)
        loc.save()

        rms2 = make_loc(code="wrms",
                        name="Test RMS 2",
                        type="Regional Medical Store",
                        domain=domain.name,
                        parent=region)
        rms2.save()

        cms = make_loc(code="cms",
                       name="Central Medical Stores",
                       type="Central Medical Store",
                       domain=domain.name,
                       parent=national)
        cms.save()

        loc2 = make_loc(code="tf",
                        name="Test Facility",
                        type="CHPS Facility",
                        domain=domain.name,
                        parent=region)
        loc2.save()

        supply_point_id = loc.linked_supply_point().get_id
        supply_point_id2 = loc2.linked_supply_point().get_id

        cls.user1 = bootstrap_user(username='******',
                                   first_name='test1',
                                   last_name='test1',
                                   domain=domain.name,
                                   home_loc=loc)
        cls.user2 = bootstrap_user(username='******',
                                   domain=domain.name,
                                   home_loc=loc2,
                                   first_name='test2',
                                   last_name='test2',
                                   phone_number='222222',
                                   user_data={'role': ['In Charge']})
        FacilityInCharge.objects.create(user_id=cls.user2.get_id,
                                        location=loc2.sql_location)
        cls.user3 = bootstrap_user(username='******',
                                   domain=domain.name,
                                   home_loc=loc2,
                                   first_name='test3',
                                   last_name='test3',
                                   phone_number='333333')
        cls.rms_user = bootstrap_user(username='******',
                                      domain=domain.name,
                                      home_loc=rms2,
                                      first_name='test4',
                                      last_name='test4',
                                      phone_number='44444')
        cls.cms_user = bootstrap_user(username='******',
                                      domain=domain.name,
                                      home_loc=cms,
                                      first_name='test5',
                                      last_name='test5',
                                      phone_number='55555')
        cls.region_user = bootstrap_user(username='******',
                                         domain=domain.name,
                                         home_loc=region,
                                         first_name='test6',
                                         last_name='test6',
                                         phone_number='66666')
        cls.without_location = bootstrap_user(username='******',
                                              domain=domain.name,
                                              first_name='test7',
                                              last_name='test7',
                                              phone_number='77777')
        try:
            XFormInstance.get(docid='test-xform')
        except ResourceNotFound:
            xform = XFormInstance(_id='test-xform')
            xform.save()

        sql_location = loc.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = loc2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = rms2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = cms.sql_location
        sql_location.products = []
        sql_location.save()

        config = CommtrackConfig.for_domain(domain.name)
        config.use_auto_consumption = False
        config.individual_consumption_defaults = True
        config.actions.append(
            CommtrackActionConfig(action='receipts',
                                  keyword='rec',
                                  caption='receipts'))
        config.consumption_config = ConsumptionConfig(
            use_supply_point_type_default_consumption=True,
            exclude_invalid_periods=True)
        config.save()

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id,
                                                 supply_point_id, 8)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id,
                                                 supply_point_id, 5)

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id,
                                                 supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id,
                                                 supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p5.get_id,
                                                 supply_point_id2, 10)
예제 #17
0
    def setUpClass(cls):
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.loc1 = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=TEST_DOMAIN)
        cls.loc2 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN)
        cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN)

        cls.user1 = bootstrap_user(
            username='******', phone_number='1111', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test1',
            user_data={
                'role': []
            }
        )
        cls.user2 = bootstrap_user(
            username='******', phone_number='2222', home_loc=cls.loc1, domain=TEST_DOMAIN,
            first_name='test', last_name='test2',
            user_data={
                'role': ['Other'],
                'needs_reminders': "False"
            }
        )

        cls.user3 = bootstrap_user(
            username='******', phone_number='3333', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test3',
            user_data={
                'role': ['Nurse'],
                'needs_reminders': "True"
            }
        )

        cls.in_charge = bootstrap_user(
            username='******', phone_number='4444', home_loc=cls.loc2, domain=TEST_DOMAIN,
            first_name='test', last_name='test4',
            user_data={
                'role': ['In Charge']
            }
        )

        cls.web_user = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username='******',
            password='******',
            email='*****@*****.**',
            location=cls.loc2,
            phone_number='5555'
        )

        EWSExtension.objects.create(
            domain=TEST_DOMAIN,
            user_id=cls.web_user.get_id,
            sms_notifications=True,
            location_id=cls.loc2.get_id
        )

        cls.web_user2 = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username='******',
            password='******',
            email='*****@*****.**',
            location=cls.region,
            phone_number='6666'
        )

        set_sms_notifications(TEST_DOMAIN, cls.web_user2, True)

        FacilityInCharge.objects.create(
            user_id=cls.in_charge.get_id,
            location=cls.loc2.sql_location
        )

        cls.product = Product(
            domain=TEST_DOMAIN,
            name='Test Product',
            code_='tp',
            unit='each'
        )
        cls.product.save()

        cls.product2 = Product(
            domain=TEST_DOMAIN,
            name='Test Product2',
            code_='tp2',
            unit='each'
        )
        cls.product2.save()

        sql_product = SQLProduct.objects.get(product_id=cls.product.get_id)
        sql_product2 = SQLProduct.objects.get(product_id=cls.product2.get_id)

        sql_location1 = cls.loc1.sql_location
        sql_location2 = cls.loc2.sql_location

        sql_location1.products = [sql_product]
        sql_location2.products = [sql_product, sql_product2]
        sql_location1.save()
        sql_location2.save()
예제 #18
0
파일: utils.py 프로젝트: bazuzi/commcare-hq
    def setUpClass(cls):
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        domain = prepare_domain(TEST_DOMAIN)

        p = Product(domain=domain.name, name="Jadelle", code="jd", unit="each")
        p.save()
        p2 = Product(domain=domain.name, name="Male Condom", code="mc", unit="each")
        p2.save()
        p3 = Product(domain=domain.name, name="Lofem", code="lf", unit="each")
        p3.save()
        p4 = Product(domain=domain.name, name="Ng", code="ng", unit="each")
        p4.save()
        p5 = Product(domain=domain.name, name="Micro-G", code="mg", unit="each")
        p5.save()

        Product(domain=domain.name, name="Ad", code="ad", unit="each").save()
        Product(domain=domain.name, name="Al", code="al", unit="each").save()
        Product(domain=domain.name, name="Qu", code="qu", unit="each").save()
        Product(domain=domain.name, name="Sp", code="sp", unit="each").save()
        Product(domain=domain.name, name="Rd", code="rd", unit="each").save()
        Product(domain=domain.name, name="Ov", code="ov", unit="each").save()
        Product(domain=domain.name, name="Ml", code="ml", unit="each").save()

        national = make_loc(code="country", name="Test national", type="country", domain=domain.name)
        region = make_loc(code="region", name="Test region", type="region", domain=domain.name, parent=national)
        loc = make_loc(
            code="garms", name="Test RMS", type="Regional Medical Store", domain=domain.name, parent=national
        )
        loc.save()

        rms2 = make_loc(
            code="wrms", name="Test RMS 2", type="Regional Medical Store", domain=domain.name, parent=region
        )
        rms2.save()

        cms = make_loc(
            code="cms", name="Central Medical Stores", type="Central Medical Store", domain=domain.name, parent=national
        )
        cms.save()

        loc2 = make_loc(code="tf", name="Test Facility", type="CHPS Facility", domain=domain.name, parent=region)
        loc2.save()

        supply_point_id = loc.linked_supply_point().get_id
        supply_point_id2 = loc2.linked_supply_point().get_id

        cls.user1 = bootstrap_user(
            username="******", first_name="test1", last_name="test1", domain=domain.name, home_loc=loc
        )
        cls.user2 = bootstrap_user(
            username="******",
            domain=domain.name,
            home_loc=loc2,
            first_name="test2",
            last_name="test2",
            phone_number="222222",
            user_data={"role": ["In Charge"]},
        )
        FacilityInCharge.objects.create(user_id=cls.user2.get_id, location=loc2.sql_location)
        cls.user3 = bootstrap_user(
            username="******",
            domain=domain.name,
            home_loc=loc2,
            first_name="test3",
            last_name="test3",
            phone_number="333333",
        )
        cls.rms_user = bootstrap_user(
            username="******",
            domain=domain.name,
            home_loc=rms2,
            first_name="test4",
            last_name="test4",
            phone_number="44444",
        )
        cls.cms_user = bootstrap_user(
            username="******",
            domain=domain.name,
            home_loc=cms,
            first_name="test5",
            last_name="test5",
            phone_number="55555",
        )
        cls.region_user = bootstrap_user(
            username="******",
            domain=domain.name,
            home_loc=region,
            first_name="test6",
            last_name="test6",
            phone_number="66666",
        )
        cls.without_location = bootstrap_user(
            username="******", domain=domain.name, first_name="test7", last_name="test7", phone_number="77777"
        )
        try:
            XFormInstance.get(docid="test-xform")
        except ResourceNotFound:
            xform = XFormInstance(_id="test-xform")
            xform.save()

        sql_location = loc.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = loc2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = rms2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = cms.sql_location
        sql_location.products = []
        sql_location.save()

        config = CommtrackConfig.for_domain(domain.name)
        config.use_auto_consumption = False
        config.individual_consumption_defaults = True
        config.actions.append(CommtrackActionConfig(action="receipts", keyword="rec", caption="receipts"))
        config.consumption_config = ConsumptionConfig(
            use_supply_point_type_default_consumption=True, exclude_invalid_periods=True
        )
        config.save()

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id, 8)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id, 5)

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p5.get_id, supply_point_id2, 10)
예제 #19
0
    def setUpClass(cls):
        super(TestReminders, cls).setUpClass()
        cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.loc1 = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=TEST_DOMAIN)
        cls.loc2 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN)
        cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN)

        cls.user1 = bootstrap_user(
            username="******",
            phone_number="1111",
            home_loc=cls.loc2,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test1",
            user_data={"role": []},
        )
        cls.user2 = bootstrap_user(
            username="******",
            phone_number="2222",
            home_loc=cls.loc1,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test2",
            user_data={"role": ["Other"], "needs_reminders": "False"},
        )

        cls.user3 = bootstrap_user(
            username="******",
            phone_number="3333",
            home_loc=cls.loc2,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test3",
            user_data={"role": ["Nurse"], "needs_reminders": "True"},
        )

        cls.in_charge = bootstrap_user(
            username="******",
            phone_number="4444",
            home_loc=cls.loc2,
            domain=TEST_DOMAIN,
            first_name="test",
            last_name="test4",
            user_data={"role": ["In Charge"]},
        )

        cls.web_user = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username="******",
            password="******",
            email="*****@*****.**",
            location=cls.loc2,
            phone_number="5555",
        )

        EWSExtension.objects.create(
            domain=TEST_DOMAIN, user_id=cls.web_user.get_id, sms_notifications=True, location_id=cls.loc2.get_id
        )

        cls.web_user2 = bootstrap_web_user(
            domain=TEST_DOMAIN,
            username="******",
            password="******",
            email="*****@*****.**",
            location=cls.region,
            phone_number="6666",
        )

        set_sms_notifications(TEST_DOMAIN, cls.web_user2, True)

        FacilityInCharge.objects.create(user_id=cls.in_charge.get_id, location=cls.loc2.sql_location)

        cls.product = Product(domain=TEST_DOMAIN, name="Test Product", code_="tp", unit="each")
        cls.product.save()

        cls.product2 = Product(domain=TEST_DOMAIN, name="Test Product2", code_="tp2", unit="each")
        cls.product2.save()

        sql_product = SQLProduct.objects.get(product_id=cls.product.get_id)
        sql_product2 = SQLProduct.objects.get(product_id=cls.product2.get_id)

        sql_location1 = cls.loc1.sql_location
        sql_location2 = cls.loc2.sql_location

        sql_location1.products = [sql_product]
        sql_location2.products = [sql_product, sql_product2]
        sql_location1.save()
        sql_location2.save()
예제 #20
0
 def setUpClass(cls):
     super(EWSTestReminders, cls).setUpClass()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(TEST_DOMAIN)
예제 #21
0
 def setUpClass(cls):
     super(EWSTestReminders, cls).setUpClass()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(TEST_DOMAIN)
예제 #22
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        cls.sms_backend_mapping, cls.backend = create_backend()

        p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each')
        p.save()
        p2 = Product(domain=domain.name, name='Male Condom', code='mc', unit='each')
        p2.save()
        p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each')
        p3.save()
        p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each')
        p4.save()
        p5 = Product(domain=domain.name, name='Micro-G', code='mg', unit='each')
        p5.save()

        Product(domain=domain.name, name='Ad', code='ad', unit='each').save()
        Product(domain=domain.name, name='Al', code='al', unit='each').save()
        Product(domain=domain.name, name='Qu', code='qu', unit='each').save()
        Product(domain=domain.name, name='Sp', code='sp', unit='each').save()
        Product(domain=domain.name, name='Rd', code='rd', unit='each').save()
        Product(domain=domain.name, name='Ov', code='ov', unit='each').save()
        Product(domain=domain.name, name='Ml', code='ml', unit='each').save()

        national = make_loc(code='country', name='Test national', type='country', domain=domain.name)
        region = make_loc(code='region', name='Test region', type='region', domain=domain.name, parent=national)
        loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=domain.name,
                       parent=national)
        SupplyPointCase.create_from_location(TEST_DOMAIN, loc)
        loc.save()

        rms2 = make_loc(code="wrms", name="Test RMS 2", type="Regional Medical Store", domain=domain.name,
                        parent=region)
        SupplyPointCase.create_from_location(TEST_DOMAIN, rms2)
        rms2.save()

        cms = make_loc(code="cms", name="Central Medical Stores", type="Central Medical Store",
                       domain=domain.name, parent=national)
        SupplyPointCase.create_from_location(TEST_DOMAIN, cms)
        cms.save()

        loc2 = make_loc(code="tf", name="Test Facility", type="CHPS Facility", domain=domain.name, parent=region)
        SupplyPointCase.create_from_location(TEST_DOMAIN, loc2)
        loc2.save()

        supply_point_id = loc.linked_supply_point().get_id
        supply_point_id2 = loc2.linked_supply_point().get_id

        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(username='******', first_name='test1', last_name='test1',
                                   domain=domain.name, home_loc=loc)
        cls.user2 = bootstrap_user(username='******', domain=domain.name, home_loc=loc2,
                                   first_name='test2', last_name='test2',
                                   phone_number='222222', user_data={'role': ['In Charge']})
        cls.user3 = bootstrap_user(username='******', domain=domain.name, home_loc=loc2,
                                   first_name='test3', last_name='test3',
                                   phone_number='333333')
        cls.rms_user = bootstrap_user(username='******', domain=domain.name, home_loc=rms2,
                                      first_name='test4', last_name='test4',
                                      phone_number='44444')
        cls.cms_user = bootstrap_user(username='******', domain=domain.name, home_loc=cms,
                                      first_name='test5', last_name='test5',
                                      phone_number='55555')
        cls.region_user = bootstrap_user(username='******', domain=domain.name, home_loc=region,
                                         first_name='test6', last_name='test6',
                                         phone_number='66666')
        cls.without_location = bootstrap_user(username='******', domain=domain.name, first_name='test7',
                                              last_name='test7', phone_number='77777')
        try:
            XFormInstance.get(docid='test-xform')
        except ResourceNotFound:
            xform = XFormInstance(_id='test-xform')
            xform.save()

        sql_location = loc.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = loc2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = rms2.sql_location
        sql_location.products = []
        sql_location.save()

        sql_location = cms.sql_location
        sql_location.products = []
        sql_location.save()

        config = CommtrackConfig.for_domain(domain.name)
        config.use_auto_consumption = False
        config.individual_consumption_defaults = True
        config.actions.append(
            CommtrackActionConfig(
                action='receipts',
                keyword='rec',
                caption='receipts'
            )
        )
        config.consumption_config = ConsumptionConfig(
            use_supply_point_type_default_consumption=True,
            exclude_invalid_periods=True
        )
        config.save()

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id, 8)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id, 5)

        set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id2, 10)
        set_default_consumption_for_supply_point(TEST_DOMAIN, p5.get_id, supply_point_id2, 10)
예제 #23
0
 def setUpClass(cls):
     cls.domain = prepare_domain(TEST_DOMAIN)
     cls.sms_backend_mapping, cls.backend = create_backend()
예제 #24
0
 def setUpClass(cls):
     super(SMSNotificationTestCase, cls).setUpClass()
     cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend()
     cls.domain = prepare_domain(cls.TEST_DOMAIN)