Beispiel #1
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        mohsw = make_loc(code="moh1", name="Test MOHSW 1", type="MOHSW", domain=domain.name)

        msdzone = make_loc(code="msd1", name="MSD Zone 1", type="MSDZONE",
                           domain=domain.name, parent=mohsw)

        region = make_loc(code="reg1", name="Test Region 1", type="REGION",
                          domain=domain.name, parent=msdzone)
        cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT",
                            domain=domain.name, parent=region)
        cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY",
                                domain=domain.name, parent=cls.district)
        cls.facility.metadata['group'] = 'B'
        cls.facility2 = make_loc(code="loc2", name="Test Facility 2", type="FACILITY",
                                 domain=domain.name, parent=cls.district)
        cls.facility2.metadata['group'] = 'C'
        cls.facility.save()
        cls.facility2.save()

        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(
            cls.facility, username='******', domain=domain.name, home_loc='loc1', phone_number='5551234',
            first_name='test', last_name='Test'
        )
        bootstrap_user(cls.facility2, username='******', domain=domain.name, home_loc='loc2',
                       phone_number='5555678', first_name='test1', last_name='Test')
        bootstrap_user(cls.district, username='******', domain=domain.name, home_loc='dis1', phone_number='555',
                       first_name='test1', last_name='Test')
        bootstrap_user(cls.district, username='******', domain=domain.name, phone_number='111',
                       first_name='MSD', last_name='Person', user_data={'role': 'MSD'})
Beispiel #2
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        mohsw = make_loc(code="moh1", name="Test MOHSW 1", type="MOHSW", domain=domain.name)

        region = make_loc(code="reg1", name="Test Region 1", type="REGION",
                          domain=domain.name, parent=mohsw)

        district = make_loc(code="dis1", name="Test District 1", type="DISTRICT",
                            domain=domain.name, parent=region)
        facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY",
                            domain=domain.name, parent=district)
        facility2 = make_loc(code="loc2", name="Test Facility 2", type="FACILITY",
                             domain=domain.name, parent=district)
        test.bootstrap(TEST_BACKEND, to_console=True)
        bootstrap_user(facility, username='******', domain=domain.name, home_loc='loc1', phone_number='5551234',
                       first_name='stella', last_name='Test')
        bootstrap_user(facility2, username='******', domain=domain.name, home_loc='loc2', phone_number='5555678',
                       first_name='bella', last_name='Test')
        bootstrap_user(district, username='******', domain=domain.name, home_loc='dis1', phone_number='555',
                       first_name='trella', last_name='Test')
        bootstrap_user(district, username='******', domain=domain.name, phone_number='111',
                       first_name='MSD', last_name='Person', user_data={'role': 'MSD'})

        p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each')
        p.save()
        p2 = Product(domain=domain.name, name='Mc', code='mc', unit='each')
        p2.save()
Beispiel #3
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()
Beispiel #4
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()
            self.ct_settings.save()

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #5
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.loc = make_loc('loc1')

        self.reporters = dict((k, bootstrap_user(self, **v)) for k, v in REPORTING_USERS.iteritems())
        # backwards compatibility
        self.user = self.reporters['roaming']

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(self, **APPROVER_USER)
        self.packer = bootstrap_user(self, **PACKER_USER)

        self.users = self.reporters.values() + [self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
Beispiel #6
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.user = bootstrap_user(**MAIN_USER)
        self.verified_number = self.user.get_verified_number()

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(**APPROVER_USER)
        self.packer = bootstrap_user(**PACKER_USER)

        self.users = [self.user, self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
Beispiel #7
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.loc = make_loc('loc1')

        self.reporters = dict((k, bootstrap_user(self, **v)) for k, v in REPORTING_USERS.iteritems())
        # backwards compatibility
        self.user = self.reporters['roaming']

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(self, **APPROVER_USER)
        self.packer = bootstrap_user(self, **PACKER_USER)

        self.users = self.reporters.values() + [self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
Beispiel #8
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        mohsw = make_loc(code="moh1", name="Test MOHSW 1", type="MOHSW", domain=domain.name)

        msdzone = make_loc(code="msd1", name="MSD Zone 1", type="MSDZONE",
                          domain=domain.name, parent=mohsw)

        region = make_loc(code="reg1", name="Test Region 1", type="REGION",
                          domain=domain.name, parent=msdzone)

        district = make_loc(code="dis1", name="Test District 1", type="DISTRICT",
                            domain=domain.name, parent=region)
        district2 = make_loc(code="d10101", name="Test District 2", type="DISTRICT",
                             domain=domain.name, parent=region)
        facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY",
                            domain=domain.name, parent=district)
        facility2 = make_loc(code="loc2", name="Test Facility 2", type="FACILITY",
                             domain=domain.name, parent=district)
        facility3 = make_loc(
            code="d31049", name="Test Facility 3", type="FACILITY", domain=domain.name, parent=district
        )
        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(
            facility, username='******', domain=domain.name, home_loc='loc1', phone_number='5551234',
            first_name='stella', last_name='Test'
        )
        bootstrap_user(facility2, username='******', domain=domain.name, home_loc='loc2', phone_number='5555678',
                       first_name='bella', last_name='Test')
        bootstrap_user(district, username='******', domain=domain.name, home_loc='dis1', phone_number='555',
                       first_name='trella', last_name='Test')
        bootstrap_user(district, username='******', domain=domain.name, phone_number='111',
                       first_name='MSD', last_name='Person', user_data={'role': 'MSD'})

        for x in xrange(1, 4):
            bootstrap_user(
                facility3,
                username='******'.format(x), domain=domain.name, phone_number=str(32346 + x),
                first_name='Person {}'.format(x), last_name='Person {}'. format(x), home_loc='d31049'
            )
            bootstrap_user(
                district2,
                username='******'.format(x), domain=domain.name, phone_number=str(32349 + x),
                first_name='dPerson {}'.format(x), last_name='dPerson {}'. format(x), home_loc='d10101'
            )

        create_products(cls, domain.name, ["id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc", "ip"])
 def setUp(self):
     self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
     self.domain = bootstrap_domain()
     self.user = bootstrap_user()
     self.verified_number = self.user.get_verified_number()
     self.loc = make_loc('loc1')
     self.sp = make_supply_point(self.domain.name, self.loc)
     self.products = Product.by_domain(self.domain.name)
     self.assertEqual(3, len(self.products))
     self.spps = {}
     for p in self.products:
         self.spps[p.code] = make_supply_point_product(self.sp, p._id)
Beispiel #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()
Beispiel #11
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config(
            )

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [
            bootstrap_user(self, **user_def)
            for user_def in self.user_definitions
        ]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN,
                           name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name),
                               key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #12
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #13
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.domain.location_types = [
            LocationType(
                name='state',
                allowed_parents=[''],
                administrative=True
            ),
            LocationType(
                name='district',
                allowed_parents=['state'],
                administrative=True
            ),
            LocationType(
                name='block',
                allowed_parents=['district'],
                administrative=True
            ),
            LocationType(
                name='village',
                allowed_parents=['block'],
                administrative=True
            ),
            LocationType(
                name='outlet',
                allowed_parents=['village']
            ),
        ]
        self.domain.save()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #14
0
    def setUpClass(cls):
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.sms_backend_mapping, cls.backend = create_backend()
        test.bootstrap(TEST_BACKEND, to_console=True)
        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']
            }
        )

        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']
            }
        )

        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'
        )

        set_sms_notifications(TEST_DOMAIN, cls.web_user, True)

        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()

        cls.loc1.save()
        cls.loc2.save()
Beispiel #15
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)
Beispiel #16
0
    def setUpClass(cls):
        domain = prepare_domain(TEST_DOMAIN)
        mohsw = make_loc(code="moh1",
                         name="Test MOHSW 1",
                         type="MOHSW",
                         domain=domain.name)

        msdzone = make_loc(code="msd1",
                           name="MSD Zone 1",
                           type="MSDZONE",
                           domain=domain.name,
                           parent=mohsw)

        region = make_loc(code="reg1",
                          name="Test Region 1",
                          type="REGION",
                          domain=domain.name,
                          parent=msdzone)

        district = make_loc(code="dis1",
                            name="Test District 1",
                            type="DISTRICT",
                            domain=domain.name,
                            parent=region)
        district2 = make_loc(code="d10101",
                             name="Test District 2",
                             type="DISTRICT",
                             domain=domain.name,
                             parent=region)
        facility = make_loc(code="loc1",
                            name="Test Facility 1",
                            type="FACILITY",
                            domain=domain.name,
                            parent=district)
        facility2 = make_loc(code="loc2",
                             name="Test Facility 2",
                             type="FACILITY",
                             domain=domain.name,
                             parent=district)
        facility3 = make_loc(code="d31049",
                             name="Test Facility 3",
                             type="FACILITY",
                             domain=domain.name,
                             parent=district)
        test.bootstrap(TEST_BACKEND, to_console=True)
        cls.user1 = bootstrap_user(facility,
                                   username='******',
                                   domain=domain.name,
                                   home_loc='loc1',
                                   phone_number='5551234',
                                   first_name='stella',
                                   last_name='Test')
        bootstrap_user(facility2,
                       username='******',
                       domain=domain.name,
                       home_loc='loc2',
                       phone_number='5555678',
                       first_name='bella',
                       last_name='Test')
        bootstrap_user(district,
                       username='******',
                       domain=domain.name,
                       home_loc='dis1',
                       phone_number='555',
                       first_name='trella',
                       last_name='Test')
        bootstrap_user(district,
                       username='******',
                       domain=domain.name,
                       phone_number='111',
                       first_name='MSD',
                       last_name='Person',
                       user_data={'role': 'MSD'})

        for x in xrange(1, 4):
            bootstrap_user(facility3,
                           username='******'.format(x),
                           domain=domain.name,
                           phone_number=str(32346 + x),
                           first_name='Person {}'.format(x),
                           last_name='Person {}'.format(x),
                           home_loc='d31049')
            bootstrap_user(district2,
                           username='******'.format(x),
                           domain=domain.name,
                           phone_number=str(32349 + x),
                           first_name='dPerson {}'.format(x),
                           last_name='dPerson {}'.format(x),
                           home_loc='d10101')

        create_products(cls, domain.name, [
            "id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc",
            "ip"
        ])